SCENARIO: Hi, i'm wondering if there is a function in VBA Excel to hide row or unhide rows.
SOLUTION:
Selection.EntireRow.Hidden = True
...will hide the rows and...
Selection.EntireRow.Hidden = False
...will display them..
A simple routine to use them could be...
Example to hide a range of rows previously shown:
Sub Hide() RowShow (4, 4, True) End Sub
Example to show a range of rows previously hidden:
Sub Show() RowShow (4, 4, False) End Sub
And this is the function to declare to use the above examples:
Function RowShow(myRow1 As Double, myRow2 As Double, bStatus As Boolean) If bStatus = True Then bStatus = False Else bStatus = True Rows(myRow1 & ":" & myRow2).Select Selection.EntireRow.Hidden = bStatus End Function
Where myRow1 and myRow2 are the row numbers, so if you want to hide a single row (for example: 4) you enter the same number twice (4,4), or you enter the start and end point for a number of rows (for example: 5 to 10)
SOURCE | LINK (Wrox.com) | LANGUAGE | ENGLISH |