+ Reply to Thread
Results 1 to 5 of 5

Macro to Auto hide certain rows in a calendar or Time Sheet.

  1. #1
    Registered User
    Join Date
    10-02-2019
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    2016
    Posts
    36

    Lightbulb Macro to Auto hide certain rows in a calendar or Time Sheet.

    Hi,
    I am trying to create a Driver's Overtime Sheet. I want to select any month in cell C2 & the relevant dates are filled in the subsequent 31 rows. But the problem is that in case of February, April etc. (Months having <=30 days), some dates of the next month are displayed. I want a macro to automatically hide that/those rows when the month is changed in cell C2 (most probably with a worksheet change event).
    Any help is highly appreciated.
    Thanks in advance.
    Attached Files Attached Files
    Last edited by excellon; 10-02-2019 at 02:07 PM.

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,611

    Re: Macro to Auto hide certain rows in a calendar or Time Sheet.

    Hello excellon and Welcome to Excel Forum.
    The following won't hide a row, however it will suppress the display of days that are not in the current (as selected in cell C2) month.
    Paste the following into cell A6 and copy down: =IF(MONTH(A5+1)=MONTH(C$2),A5+1,"")
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Registered User
    Join Date
    10-02-2019
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    2016
    Posts
    36

    Re: Macro to Auto hide certain rows in a calendar or Time Sheet.

    Hi JeteMc,
    Thanks for your help.
    As you said, your formula did not hide the next month rows but kept them blank though the last row showed error value as its predecessor had no month. so, I put an IFERROR function to the whole formula and now the next month rows are blank.
    Now, I would like to hide those 1 or 2 blank rows upon the selection of the month in C2.
    Can you please help further?
    Thanks again.

  4. #4
    Registered User
    Join Date
    10-02-2019
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    2016
    Posts
    36

    Re: Macro to Auto hide certain rows in a calendar or Time Sheet.

    Well, I found the code in the stackoverflow Forum.

    I have triggered the code with Worksheet Change & it worked:

    Please Login or Register  to view this content.
    Thanks to excelforum.
    Last edited by Pepe Le Mokko; 10-05-2019 at 03:02 AM.

  5. #5
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,611

    Re: Macro to Auto hide certain rows in a calendar or Time Sheet.

    Glad that you found a solution. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

+ 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. Stuck with slow macro - Hide rows and auto fit
    By dhrconcept in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-10-2016, 05:09 AM
  2. Macro/VBA for auto hide unhide rows
    By louvaek in forum Excel Programming / VBA / Macros
    Replies: 53
    Last Post: 11-29-2014, 05:36 PM
  3. Macro to auto hide rows in a specific range
    By morayman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-16-2014, 10:03 AM
  4. [SOLVED] Macro To Auto-Hide Rows
    By TheRustyScupper in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-23-2013, 02:01 AM
  5. Auto Hide & Unhide Rows Upon Sheet Selection
    By Sleeper in forum Excel General
    Replies: 4
    Last Post: 01-24-2013, 02:00 PM
  6. Need Macro to Auto hide rows
    By cmwood in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2013, 10:47 AM
  7. Auto-hide certain rows (possibly macro driven)
    By bgreen in forum Excel General
    Replies: 1
    Last Post: 06-23-2009, 06:13 PM

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