I have been trying to create some code in exel that looks at the value of a cell and then performs a Hide action if the number in the cell is less than 99.
Here is my idea:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim CellValue As Integer
CellValue = Target.Value("$D$68")
If CellValue <= 99 Then
Rows("70:77").Hidden = True
Else
Rows("70:77").Hidden = False
Application.ScreenUpdating = True
End If
End Sub
I believe the problem here is that I cannot obtain the a reference to that cell?
How could I do this?
I suppose you should replace
CellValue = Target.Value("$D$68")byCellValue = Target.Value– Target as range has everything to return value, you have wrong syntax.Manually value from
D68may be returned asCellValue = Range("D68").Value.