Reputation: 4305
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?
Upvotes: 0
Views: 105
Reputation: 7304
I suppose you should replace CellValue = Target.Value("$D$68")
by CellValue = Target.Value
- Target as range has everything to return value, you have wrong syntax.
Manually value from D68
may be returned as CellValue = Range("D68").Value
.
Upvotes: 4