Makro in excel

T

Ted

Hi!
I want to make a macro that hides the hole row if a cell in that row has the
value 0 (zero).
Dont know how to do that.
Can anyone help me with a tip how to accomplish this.
:)
 
B

Bob Phillips

Any cell?

Rows(5).Hidden = Application.Countif(Rows(5),0) > 0

or a specific cell?

Rows(5).Hidden = Range("M5") .value = 0

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
T

Ted

I want the macro to go thru the hole worksheet row by row.
If the cell e3,e4 and so on are zero the row should be hidden.

"Bob Phillips" skrev:
 
S

Stefi

Hi Ted,

Try this:

Sub hiderow()
Dim whichrng As Range
Set whichrng = Range("A1:A10") 'adjust range to your needs!
For Each cell In whichrng
If cell = 0 And Not IsEmpty(cell) Then
Rows(cell.Row).Hidden = True
End If
Next cell
End Sub

Regards,
Srefi

„Ted†ezt írta:
 
B

Bob Phillips

For i = 1 To Cells(Rows.Count,"E").End(xlUp).Row
Rows(i).Hidden = Cells(i,"E").Value = 0
Next i

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
B

Bob Phillips

That should be

For i = 1 To Cells(Rows.Count, "E").End(xlUp).Row
Rows(i).Hidden = Cells(i, "E").Value = 0 And _
Not IsEmpty(Cells(i, "E").Value)
Next i


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Top