View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Hide rows with VBA

Sub HideRows()
Rows.Hidden = False

Range(Cells(1,1),ActiveCell.Offset(-1,0)).EntireRow.Hidden = True
End Sub

Assign that to my button (forms toolbar or menu button) or put similar code
in the click event for a commandbarbutton.
--
Regards,
Tom Ogilvy

"pantelis" wrote in message
...
Hi all,

Need some quick help.

When I run a simulation it generates 10 rows of data for years 1987(row1)

to
2002(row16) which is placed into sheet2 of the workbook.

I want the macro to look at sheet1,cell A1, say this has year 1995 in the
cell, and when I press the macro button this would hide rows 1987 up to

1994
and therefore display only 1995 to 2002.

So the only variable is cell A1 i.e. 1995

Thanks in advance to anyone's help

Pantelis