what is wrong with this code?
Private Sub Worksheet_Change(ByVal Target As Range)
If IsEmpty(Sheet5.Range("A26").Value) = True Then
Sheet5.Rows("26:27").EntireRow.Hidden = True
ElseIf IsEmpty(Sheet5.Range("A26").Value) = False Then
Sheet5.Rows("26:27").EntireRow.Hidden = False
End If
End Sub
Can you please try it?
If IsEmpty(Worksheets("Sheet5").Range("A26").Value) = True Then
Worksheets("Sheet5").Rows("26:27").EntireRow.Hidden = True
ElseIf IsEmpty(Worksheets("Sheet5").Range("A26").Value) = False Then
Worksheets("Sheet5").Rows("26:27").EntireRow.Hidden = False
End If
Useful link:
https://learn.microsoft.com/en-us/office/vba/api/excel.range(object)
I found an answer!
Private Sub Worksheet_Calculate()
Application.EnableEvents = False
If Sheet5.Range("A26").Value = "" Then
Sheet5.Rows("26:27").EntireRow.Hidden = True
Else
Sheet5.Rows("26:27").EntireRow.Hidden = False
End If
End Sub
Application.EnableEvents = True
I had to change
Private Sub Worksheet_Change(ByVal Target As Range)
to
Private Sub Worksheet_Calculate()
I needed to use calculate because the "" is created by formula therefore a calculation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.