Hi Everyone,
Below code runs in sec.Is there any way to run it faster? Any magical touch from you experts?
Thank you for the help.
Baha
Below code runs in sec.Is there any way to run it faster? Any magical touch from you experts?
Thank you for the help.
Baha
Code:
Sub ColorMeUp()
Dim cel As Range
Dim LastRow, LastRow2 As Long
Dim sht As Worksheet
Dim FindId As Range
Application.ScreenUpdating = False
For Each sht In Worksheets
Select Case sht.Name
Case Is = Range("ActiveRoster").Text '"MorningFloorMap", "SwingFloorMap", "GraveFloorMap"
LastRow = sht.Range("A65536").End(xlUp).Row
LastRow2 = Sheets("ColorCode").Range("A65536").End(xlUp).Row
' FOR THE MAIN DEALERS
For Each cel In sht.Range("D2:D" & LastRow)
On Error Resume Next
If cel.Value <> 0 Or cel <> "" Then
With Sheets("ColorCode").Range("A2:A" & LastRow2)
Set FindId = .Find(What:=cel.Value, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not FindId Is Nothing Then
If FindId.Offset(0, 1) = True Then
With cel.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
With cel.Offset(0, 1).Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If FindId.Offset(0, 2) = True Then
With cel.Font
.FontStyle = "Bold"
.Color = 255
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 255
End With
Else
With cel.Font
.FontStyle = "Bold"
.Color = 8
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 8
End With
End If
End If
End With
End If
Next cel
'FOR THE DEALER SWING
For Each cel In sht.Range("H2:H" & LastRow)
On Error Resume Next
If cel.Value <> 0 Or cel <> "" Then
With Sheets("ColorCode").Range("A2:A" & LastRow2)
Set FindId = .Find(What:=cel.Value, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not FindId Is Nothing Then
If FindId.Offset(0, 1) = True Then
With cel.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
With cel.Offset(0, 1).Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If FindId.Offset(0, 2) = True Then
With cel.Font
.FontStyle = "Bold"
.Color = 255
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 255
End With
Else
With cel.Font
.FontStyle = "Bold"
.Color = 8
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 8
End With
End If
End If
End With
End If
Next cel
'FOR THE SUPERVISORS
For Each cel In sht.Range("L2:L" & LastRow)
On Error Resume Next
If cel.Value <> 0 Or cel <> "" Then
With Sheets("ColorCode").Range("A2:A" & LastRow2)
Set FindId = .Find(What:=cel.Value, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not FindId Is Nothing Then
If FindId.Offset(0, 1) = True Then
With cel.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
With cel.Offset(0, 1).Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If FindId.Offset(0, 2) = True Then
With cel.Font
.FontStyle = "Bold"
.Color = 255
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 255
End With
Else
With cel.Font
.FontStyle = "Bold"
.Color = 8
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 8
End With
End If
End If
End With
End If
Next cel
'FOR SWING SUPERVISORS
For Each cel In sht.Range("P2:P" & LastRow)
On Error Resume Next
If cel.Value <> 0 Or cel <> "" Then
With Sheets("ColorCode").Range("A2:A" & LastRow2)
Set FindId = .Find(What:=cel.Value, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not FindId Is Nothing Then
If FindId.Offset(0, 1) = True Then
With cel.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
With cel.Offset(0, 1).Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If FindId.Offset(0, 2) = True Then
With cel.Font
.FontStyle = "Bold"
.Color = 255
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 255
End With
Else
With cel.Font
.FontStyle = "Bold"
.Color = 8
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 8
End With
End If
End If
End With
End If
Next cel
Case Is = "Spares"
LastRow = sht.Range("A65536").End(xlUp).Row
LastRow2 = Sheets("ColorCode").Range("A65536").End(xlUp).Row
' FOR THE MAIN DEALERS
For Each cel In sht.Range("C2:C" & LastRow)
On Error Resume Next
If cel.Value <> 0 Or cel <> "" Then
With Sheets("ColorCode").Range("A2:A" & LastRow2)
Set FindId = .Find(What:=cel.Value, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not FindId Is Nothing Then
If FindId.Offset(0, 1) = True Then
With cel.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
With cel.Offset(0, 1).Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If FindId.Offset(0, 2) = True Then
With cel.Font
.FontStyle = "Bold"
.Color = 8
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 8
End With
Else
With cel.Font
.FontStyle = "Bold"
.Color = 8
End With
With cel.Offset(0, 1).Font
.FontStyle = "Bold"
.Color = 8
End With
End If
End If
End With
End If
Next cel
End Select
Next sht
HighlightingShifts
End Sub