+ Reply to Thread
Results 1 to 8 of 8

moving and coloring rows by date

  1. #1
    Registered User
    Join Date
    08-01-2017
    Location
    U.S. Tennessee
    MS-Off Ver
    2010
    Posts
    12

    moving and coloring rows by date

    The file I have attached is a test file for what I'm trying to do. In the file I'm going to be using most of the dates in the Dates column are doing to be future dates. What I want is for the the row of the table to be highlight in red when the date is <= today (today or in the past) for each row and then move those rows to the top of the sheet just under my header row. So there's three rows in my sheet that have tomorrows date in them then tomorrow morning when I get to work and open the file I'd like all three of those rows to be highlight in red and stacked one on top of the other at the top of my sheet under the header row. I'd like this to run every time the workbook is opened in excel. I've attached the file, what kind of adjustments do I need to make in the Macro? Thanks for your help.

    Okay, so the Attachment button is just giving me a thing white bar, there's now file browser for selecting my file. I'm stuck here with this forum.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: moving and coloring rows by date

    .
    If you don't mind having the Red Highlighted rows moved to Sheet 2 instead ... paste this macro into a Routine Module:
    (Sorry, it's late here, need sleep. This was already in my 'toolbox' .)

    Please Login or Register  to view this content.

    Paste this macro into the ThisWorkbook module :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-01-2017
    Location
    U.S. Tennessee
    MS-Off Ver
    2010
    Posts
    12

    Re: moving and coloring rows by date

    image.jpg

    I would like the VBA to find all the dates in column G that are today's date or older and for each row that meets that criteria I would like to highlight the row from cells A:J and then move those rows to rows position three stacking on top of each other and pushing everything under it down. I would upload the file but I don't see an upload option so I've uploaded in image instead. Thanks for your help, it's close but what's its doing in my file is only highlighting the single cell and then immediately deleting the entire row.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: moving and coloring rows by date

    .
    Paste into a Routine Module:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-01-2017
    Location
    U.S. Tennessee
    MS-Off Ver
    2010
    Posts
    12

    Re: moving and coloring rows by date

    Quote Originally Posted by Logit View Post
    .
    Paste into a Routine Module:

    Please Login or Register  to view this content.
    I pasted that code into the code for sheet1 as well as into the Module1 code section but after opening the file nothing happened, the out of date rows remained exactly where they were and noting was colored in. I also tried to run the macros manually but got the same thing?

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: moving and coloring rows by date

    .
    Download the example workbook in Post #4.

    Highlight in YELLOW the following lines :

    Highlight.jpg


    Then, inside the macro code itself, comment out the following lines :

    Code.jpg

    Then run the project. You should see that the macro is selecting the dates <= TODAY and pasting those rows at the top of the sheet.


    Is the positioning where the rows are being pasted accurate for your needs ?
    (Disregard the command button says Paste Sht 2. Obviously it pastes to Sheet 1. The caption needs to be edited.

  7. #7
    Registered User
    Join Date
    08-01-2017
    Location
    U.S. Tennessee
    MS-Off Ver
    2010
    Posts
    12

    Re: moving and coloring rows by date

    Quote Originally Posted by Logit View Post
    .
    Download the example workbook in Post #4.

    Highlight in YELLOW the following lines :

    Attachment 532497


    Then, inside the macro code itself, comment out the following lines :

    Attachment 532498

    Then run the project. You should see that the macro is selecting the dates <= TODAY and pasting those rows at the top of the sheet.


    Is the positioning where the rows are being pasted accurate for your needs ?
    (Disregard the command button says Paste Sht 2. Obviously it pastes to Sheet 1. The caption needs to be edited.
    Thanks. I see that it's working pretty well on your file. I'll try and tweak it to my needs if I can. I eventually need it to run on four different sheet with specific names, (Site1, Site2, Annex Diets, & 28 Diets), I need the same operation to take place for each of those sheets all moving outdate rows to the top of their own sheet. I wish it would let me upload the file but the upload button doesn't work. Thanks again for you help, I should be able to take it from here.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: moving and coloring rows by date

    Great !

    Best luck !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Moving Rows Based on the Input of a Date
    By Building in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-17-2014, 04:42 PM
  2. Macro to copy rows based on moving date and paste the rows into an identical sheet
    By ivandc1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2014, 11:59 AM
  3. Coloring rows according to date in a column
    By 3nduranc3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2013, 10:55 AM
  4. Moving rows of data to a new sheet based on date criteria
    By kaufmann98 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2012, 01:41 PM
  5. Replies: 1
    Last Post: 05-06-2012, 11:25 AM
  6. Replies: 0
    Last Post: 09-29-2011, 01:56 PM
  7. coloring in rows
    By koba in forum Excel General
    Replies: 9
    Last Post: 11-10-2005, 02:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1