Monday 21 May 2018

VBA Code to hide rows with previous dates in excel | Macro to hide rows based on dates in excel

VBA Code to hide rows with previous dates in excel | Macro to hide rows based on dates in excel




Before applying Macro, follow the steps to apply Macro on Excel.


Open Excel Sheet

Press Alt + F11 Key 


Go to the Insert Menu and Click on new Module


in New Module copy and paste the above VBA code and save.


Now Press Alt + F8  and new windows will open which is shown in below figure,


in that windows you will ask to enter a key to create shortcut for Paste Special


Enter a letter in the box. 
Sub Hide_Dates()

Dim MyRange As Range, c As Range

Set MyRange = Range("H2:H4436")

MyRange.EntireRow.Hidden = False

For Each c In MyRange

    If IsDate(c.Value) And c.Value < Date Then

        c.EntireRow.Hidden = True

    End If

Next

End Sub

No comments:

Post a Comment