+ Reply to Thread
Results 1 to 7 of 7

Macro to hide rows based on today's date and auto run it

  1. #1
    Registered User
    Join Date
    03-28-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007
    Posts
    5

    Macro to hide rows based on today's date and auto run it

    Hi,

    I'd like to create a macro that will hide rows based on today's date. I'd like to hide any rows that include dates that are one week old or older. I'd then like the macro to run automatically on opening the workbook. Some dates have passed already. Ideally, the rows with dates that are older than 1 week, would hide automatically when I open Excel.

    Sample workbook:
    Cells A3:A22 have dates 4/1/14 thru 4/20/14
    Cells B3:G22 have other data

    I'd like to create a macro and have it run automatically that will hide any row that has a date in column A that is 7 days or older. In this case, if I open the workbook on 4/15/14, the macro would hide rows 3 thru 10, upon opening.

    Please help.

    Thanks,
    EVT123

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Macro to hide rows based on today's date and auto run it

    Please Login or Register  to view this content.
    Change the name of the sheet to the one you want it to run on.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    03-28-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro to hide rows based on today's date and auto run it

    Solus,

    Thanks for the reply. This is my first experience with VBA, so forgive me if I'm doing something wrong. I opened the developer tab and pasted in your code. Then, I changed "SheetYouPick" to the name of my worksheet, per your instructions. I saved the workbook as a macro enabled workbook. Then, I closed the workbook, reopened it and the old dates that I expected to be hidden, were still there. What did I do wrong?

    Any ideas? Thanks for your help.

    EVT123

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to hide rows based on today's date and auto run it

    Another:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Macro to hide rows based on today's date and auto run it

    evt123,

    Did you save it in the workbook module? Double click ThisWorkbook shown in this picture to insert the code.

    Capture.PNG

  6. #6
    Registered User
    Join Date
    03-28-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro to hide rows based on today's date and auto run it

    Solus,

    Thanks. That was what I did wrong. Much appreciated!

    EVT123

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Macro to hide rows based on today's date and auto run it

    Glad to help. And welcome to the forum.

    If you are happy with the solution please mark the thread as [SOLVED] using the thread tools at the top.

    And on any thread you can show your appreciation to those who have helped you by clicking the * below their post.

+ 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. Hide rows if date less than today
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-28-2017, 02:22 AM
  2. [SOLVED] Auto Hide and Unhide Rows Based
    By Kosmik in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-05-2013, 10:09 AM
  3. Auto hide columns when date is before today
    By Emrytate in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2013, 06:07 AM
  4. want to auto-hide rows based on a value in that row
    By jimboryan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2013, 12:24 PM
  5. Macro to hide the columns that contains date < today
    By Darold in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-30-2010, 10:35 AM

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