VBA - hiding rows

A

Andrew Appel

How can I hide rows in Excel, using VBA, upon an event, like a click in a
control?
THANKS!
andrew
 
C

Cliff Myers

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
 
A

Andrew Appel

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?
 
R

Ron de Bruin

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
 
A

Andrew Appel

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
 
A

Andrew Appel

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
 
Top