Hide/unhide rows

Damo10

Active Member
Joined
Dec 13, 2010
Messages
460
Hi,

I would like to be able to hide or unhide some rows depending on how many days there are in the month, i.e. if the month has 28 days then hide rows 91:99, if the month has 20 days then hide rows 94:99 or if the month has 31 dayd hide rows 97:99. I would like this to be run of the date that is entered in cell E4

Any help is most welcome

Regards Damian
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Don't understand your criteria.
What would determine that a month has only 20 days?
 
Upvote 0
Hi,

Sorry the 20 was a typing mistake, it should have bee 30.

What i would like is if the date in cell E4 = 01/02/11 (28 day month) then rows 91:99 are hidden, if the date = 01/04/11 (30 day month) then rows 94:99 are hidden etc, if the month has 31 days then all rows are visible

Regards
 
Upvote 0
This WorkSheet code works in my test workbook:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$E$4" Then
        Rows("91:99").EntireRow.Hidden = False
        eom = Day(DateSerial(Year(Range("E4")), Month(Range("E4")) + 1, 1) - 1)
        If eom = 28 Then Rows("91:99").EntireRow.Hidden = True
        If eom = 30 Then Rows("94:99").EntireRow.Hidden = True
    End If
End Sub
Code runs when cell E4 is changed.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,253
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top