andrewb90
Well-known Member
- Joined
- Dec 16, 2009
- Messages
- 1,077
I am hoping this is pretty minor, but I have a macro that I am trying to run, and when I do, it seems to interfere with my selection change code on my sheet.
They both work independently, but when they are on the same sheet I have issues. Can anybody help with this?
Here is one of my macros that I run:
Here is my selection change:
They both work independently, but when they are on the same sheet I have issues. Can anybody help with this?
Here is one of my macros that I run:
Code:
Sub filter()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim Cell As Range
With ActiveSheet
Unprotect "majinbuu"
For Each Cell In .Range("E4:EE4").Cells
If .Range("A4").Value = "" Then
With Cell
.EntireColumn.Hidden = .Value <> .Parent.Range("A3").Value
End With
Else
With Cell
.EntireColumn.Hidden = Not ((.Value >= .Parent.Range("A3").Value) And (.Value <= .Parent.Range("A4").Value))
End With
End If
Next Cell
Protect "majinbuu"
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Here is my selection change:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Line Highlighting Tool
Range("B6:EE16").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B6:B16")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B18:EE28").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B18:B28")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B30:EE46").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B30:B46")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B48:EE57").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B48:B57")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B59:EE89").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B59:B89")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B91:EE100").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B91:B100")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B102:EE110").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B102:B110")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B112:EE136").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B112:B136")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B138:EE145").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B138:B145")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
Range("B147:EE156").Interior.Color = xlNone 'range that get colored
Set S = Application.Intersect(Range(Target.Address), Range("B147:B156")) 'range to click on
If Not S Is Nothing Then
Range("B" & Target.Row & ":EE" & Target.Row).Interior.ColorIndex = 22 'total column range
End If
End Sub