I am using a VBA code to hide some rows based on a cell value:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Activate
If Not Application.Intersect(Range("K3"), Range(Target.Address)) Is Nothing Then
Select Case Target.Value
Case Is = "Full_FC_powered": Rows("33:33").EntireRow.Hidden = True
Rows("37:38").EntireRow.Hidden = True
Rows("45:46").EntireRow.Hidden = True
Case Is = "FC_for_hotel": Rows("33:33").EntireRow.Hidden = False
Rows("37:38").EntireRow.Hidden = False
Rows("45:46").EntireRow.Hidden = False
Case Is = "DG_for_transit": Rows("33:33").EntireRow.Hidden = False
Rows("37:38").EntireRow.Hidden = False
Rows("45:46").EntireRow.Hidden = False
End Select
End If
End Sub
The code itself already works but there is one downfall: The value of 'K3' is linked to another worksheet where it gets calculated. However, if the value of K3 changes in the other worksheet, the VBA code does not automattically work. I first have to go to cell K3 and press enter.
My question: is there a way to link this code directly to another worksheet or to refresh this code when the cell values change?
Thanks in advance