VBA - hiding rows

  • Thread starter Thread starter Andrew Appel
  • Start date Start date
A

Andrew Appel

How can I hide rows in Excel, using VBA, upon an event, like a click in a
control?
THANKS!
andrew
 
I'm not sure how or what your wanting to hide but maybe this will get you
started.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Cells(1, 1) <> "" Then
ActiveCell.EntireRow.Hidden = True
End If
End Sub
What the above code will do is if cell A1 is not blank then for each cell
you click on it will hide the row.
HTH
 
Thanks! This is a good start. I'm actually trying to hide a set of rows
on a sheet when I click in a control on different sheet. Is that doable?
 
If you mean a button on Sheet1
you can use this Macro for example

Sub test()
Sheets("Sheet2").Rows("3:10").Hidden = True
End Sub
 
Perfect. Thanks!
andrew
Ron de Bruin said:
If you mean a button on Sheet1
you can use this Macro for example

Sub test()
Sheets("Sheet2").Rows("3:10").Hidden = True
End Sub
 
Thanks! Perfect!
Ron de Bruin said:
If you mean a button on Sheet1
you can use this Macro for example

Sub test()
Sheets("Sheet2").Rows("3:10").Hidden = True
End Sub
 
Back
Top