VBA Code to delete hidden rows in Excel Sheet | Macro to delete hidden rows in Excel Sheet

VBA Code to delete hidden rows in Excel Sheet | Macro to delete hidden rows in Excel Sheet




VBA Code:

Open Excel sheet and Press Alt F11

Click on Insert Button and Insert new module

Paste the below code and save.

Before saving the code you must enable the sheet as Macro Enabled Sheet.


Sub deletehidden()
For lp = 256 To 1 Step -1
If Columns(lp).EntireColumn.Hidden = True Then Columns(lp).EntireColumn.Delete Else
Next
For lp = 65536 To 1 Step -1If Rows(lp).EntireRow.Hidden = True Then Rows(lp).EntireRow.Delete Else
Next
End Sub


here in the above code change the range of rows i.e. For Lp = 65536 according to your requirement.

Comments