View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.newusers
Dave Dave is offline
external usenet poster
 
Posts: 1,388
Default hiding a row in a spreadsheet if calculated value = 0

Hi,
Try this macro:

Sub HideZeros()
A = 1 'Start Row
B = 1 'Calculated Value Column
C = 1 'Any Column which has text data in each row
Do Until Cells(A, C) = ""
If Cells(A, B).Value = 0 Then Rows(A).EntireRow.Hidden = True
A = A + 1
Loop
End Sub

You will have to change the values of A, B, C to suit your data.
A is your first Row of data (Row number)
B is the Column Number of your calculated value. This needs to be a number,
not a letter. eg, enter 5 for Column E
C is any column that has text for every row of your data. The macro
continuously checks this column for data. When it finds a blank, it will
stop. As above, enter the Column number, not the letter.

This macro just runs once, hiding rows with zero in the critical cell. If
you want a row to hide as soon as its critical cell becomes zero, then you
need an event macro, which can also be done.

Regards - Dave.