ExtraCheese
New Member
- Joined
- Sep 18, 2020
- Messages
- 12
- Office Version
- 2016
- Platform
- Windows
I'm using two subs to hide rows when a value in column D is 0.
Another sub is used to clear the contents of a single cell in column J within the hidden row (I need to keep the other data within that row).
Both subs below:
Private Sub Worksheet_Activate()
For Each c In Range("D2:D2000")
If c.Value = 0 Then
Rows(c.Row).Hidden = True
Else
Rows(c.Row).Hidden = False
End If
Next
End Sub
Private Sub Worksheet_Activate(ByVal Target As Range)
If Not Intersect(Target, Range("D2:D2000")) Is Nothing Then
If Target = 0 Then
Range("J" & Target.Row).ClearContents
End If
End If
End Sub
However, excel won't let me use worksheet_activate both times. Is there any way I can merge the two subs so that both will be executed when the worksheet is activated?
Another sub is used to clear the contents of a single cell in column J within the hidden row (I need to keep the other data within that row).
Both subs below:
Private Sub Worksheet_Activate()
For Each c In Range("D2:D2000")
If c.Value = 0 Then
Rows(c.Row).Hidden = True
Else
Rows(c.Row).Hidden = False
End If
Next
End Sub
Private Sub Worksheet_Activate(ByVal Target As Range)
If Not Intersect(Target, Range("D2:D2000")) Is Nothing Then
If Target = 0 Then
Range("J" & Target.Row).ClearContents
End If
End If
End Sub
However, excel won't let me use worksheet_activate both times. Is there any way I can merge the two subs so that both will be executed when the worksheet is activated?