automatically hiding a cell when value changes

S

swiftcode

Hi all,

I have a problem on hiding a row when the value of a cell changes.

The following macro which works if i manualy input a zero value into the
cell, but when the cell is a formula and the result is zero, it doesent work
anymore.

Can anybody please help.

Thanks in advance.

the code is as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$7" Then
If Target <= 0 Then
Cells(7, 3).EntireRow.Hidden = True
Else
Cells(7, 3).EntireRow.Hidden = False
End If
End If
End Sub
 
G

Gary''s Student

Private Sub Worksheet_Calculate()
If Range("C7").Value <= 0 Then
Cells(7, 3).EntireRow.Hidden = True
Else
Cells(7, 3).EntireRow.Hidden = False
End If
End Sub

This replaces your other macro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top