Hi all,
I have several different macros in a event change. I would like to have different macros run, based on certain cells that change.
Example:
This code I want to run when any cell is changed:
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Distro").Calculate
And this code to run only when cell F1 is changed:
If Range("GF3").Value = "2" Then 'Distro1x12
Rows("13:52").EntireRow.Hidden = True
ElseIf Range("gf3").Value = "6" Then
Rows("13:52").EntireRow.Hidden = False
End If
And this code to run only when cell F54 is changed:
End If
If Range("GF56").Value = "2" Then 'Distro2x12
Rows("66:105").EntireRow.Hidden = True
ElseIf Range("gf56").Value = "6" Then
Rows("66:105").EntireRow.Hidden = False
The combined code is below.
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Distro").Calculate
If Range("GF3").Value = "2" Then
Rows("13:52").EntireRow.Hidden = True
ElseIf Range("gf3").Value = "6" Then
Rows("13:52").EntireRow.Hidden = False
End If
If Range("GF56").Value = "2" Then
Rows("66:105").EntireRow.Hidden = True
ElseIf Range("gf56").Value = "6" Then
Rows("66:105").EntireRow.Hidden = False
End If
End Sub
Thank you!
Russ
I have several different macros in a event change. I would like to have different macros run, based on certain cells that change.
Example:
This code I want to run when any cell is changed:
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Distro").Calculate
And this code to run only when cell F1 is changed:
If Range("GF3").Value = "2" Then 'Distro1x12
Rows("13:52").EntireRow.Hidden = True
ElseIf Range("gf3").Value = "6" Then
Rows("13:52").EntireRow.Hidden = False
End If
And this code to run only when cell F54 is changed:
End If
If Range("GF56").Value = "2" Then 'Distro2x12
Rows("66:105").EntireRow.Hidden = True
ElseIf Range("gf56").Value = "6" Then
Rows("66:105").EntireRow.Hidden = False
The combined code is below.
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Distro").Calculate
If Range("GF3").Value = "2" Then
Rows("13:52").EntireRow.Hidden = True
ElseIf Range("gf3").Value = "6" Then
Rows("13:52").EntireRow.Hidden = False
End If
If Range("GF56").Value = "2" Then
Rows("66:105").EntireRow.Hidden = True
ElseIf Range("gf56").Value = "6" Then
Rows("66:105").EntireRow.Hidden = False
End If
End Sub
Thank you!
Russ