Is there a better way to wright this code? I have trouble hidding one of the columns somtimes. The names in the code are actually in row 2 in there column range. I would rather have an "IF" selection (IF $A$1 = "$R$2) etc...hide columns, but I did not know how to do that.
Any help would be appreciated.
keithb
Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set A1 = Range("A1")
If Intersect(t, A1) Is Nothing Then Exit Sub
Application.EnableEvents = False
ActiveSheet.Unprotect "jonna1"
If Target.Address = "$A$1" And Target.Text = "Keith Blankenship" Then
Range("R:R").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
If Target.Address = "$A$1" And Target.Text = "Rick Silverman" Then
Range("S:S").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
If Target.Address = "$A$1" And Target.Text = "Richard Sawyer" Then
Range("T:T").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
If Target.Address = "$A$1" And Target.Text = "Ron Naylor" Then
Range("U:U").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
If Target.Address = "$A$1" And Target.Text = "George Rodriguez" Then
Range("V:V").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
End If
End If
End If
End If
End If
Call Macro3
ActiveSheet.Protect "jonna1"
Application.EnableEvents = True
End Sub
Sub Macro3()
'
' Macro3 Macro
' Filter
'
ActiveSheet.Range("$A$2:$W$54").AutoFilter Field:=23, Criteria1:="<>"
End Sub
Any help would be appreciated.
keithb
Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set A1 = Range("A1")
If Intersect(t, A1) Is Nothing Then Exit Sub
Application.EnableEvents = False
ActiveSheet.Unprotect "jonna1"
If Target.Address = "$A$1" And Target.Text = "Keith Blankenship" Then
Range("R:R").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
If Target.Address = "$A$1" And Target.Text = "Rick Silverman" Then
Range("S:S").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
If Target.Address = "$A$1" And Target.Text = "Richard Sawyer" Then
Range("T:T").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
If Target.Address = "$A$1" And Target.Text = "Ron Naylor" Then
Range("U:U").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
If Target.Address = "$A$1" And Target.Text = "George Rodriguez" Then
Range("V:V").EntireColumn.Hidden = False
Else
Range("R:V").EntireColumn.Hidden = True
End If
End If
End If
End If
End If
Call Macro3
ActiveSheet.Protect "jonna1"
Application.EnableEvents = True
End Sub
Sub Macro3()
'
' Macro3 Macro
' Filter
'
ActiveSheet.Range("$A$2:$W$54").AutoFilter Field:=23, Criteria1:="<>"
End Sub