Ok I am starting to get somewhere but need a bit more help
This is the code I am using in another part of my worksheet and it works great. I just need to be able to add modify or create new for next part of worksheet
I need it now to look at Column P:BS to see if =AND($J2>0,$A2="Dial before you Dig",P$1>=$J2,P$1<=$K2) and it will fill in Date Columns as per my attachment
This is the code I am using in another part of my worksheet and it works great. I just need to be able to add modify or create new for next part of worksheet
Code:
Sub CondFormatMultiColour()
Application.ScreenUpdating = False
Dim wrkSchedule As Worksheet
Dim RangeA As Range, RangeF As Range, FoundWordCell As Range, Cl As Range
Dim TopRow As Long, BottomRow As Long, FoundRow As Long
Dim Booked As String
Dim Forpark As String
Dim Status As String, Word2Find1 As String, Word2Find2 As String, Word2Find3 As String, Word2Find4 As String, Word2Find5 As String, Word2Find6 As String, Word2Find7 As String, Word2Find8 As String, Word2Find9 As String, Word2Find10 As String, Word2Find11 As String, Word2Find12 As String ' Add more if you want more
Word2Find1 = "Description"
Word2Find2 = "Dial"
Word2Find3 = "Install" ' Can change these to cell ranges if you want
Word2Find4 = "Underground" ' to change the searched words easier but
Word2Find5 = "Special" ' requires a bit more code
Word2Find6 = "Play Audit"
Word2Find7 = "Bob Cat - Excavate"
Word2Find8 = "Bob Cat - Removal of Equipment"
Word2Find9 = "Bob Cat - Removal of Edging"
Word2Find10 = "Bob Cat - Removal of Mulch"
Word2Find11 = "Soil Dump"
Word2Find12 = "Bin Hire"
Status = LCase("Status")
Booked = LCase("Booked")
Set wrkSchedule = ThisWorkbook.Sheets(1) ' The worksheet
TopRow = 3 ' Highest row of data
' Find the bottom row of data
BottomRow = wrkSchedule.Columns(1).Find(What:="*", LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False, _
SearchFormat:=False).Row
' Set the range for the loop
Set RangeA = wrkSchedule.Range(wrkSchedule.Cells(TopRow, 1), wrkSchedule.Cells(BottomRow, 1))
' Start The Loop
With RangeA
For Each Cl In RangeA
If InStr(1, LCase(Cl), LCase(Word2Find1), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Status Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(217, 217, 217) ' Lightish Grey (Description)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find2), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(51, 204, 255) ' Aqua Blue (Dial)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find3), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(255, 255, 0) ' Yellow (Install)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find4), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(255, 0, 0) ' Red (Underground)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find5), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(128, 128, 0) ' Lightish Green (Special)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find6), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(255, 153, 204) ' Lightish Pink (Play Audit)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find7), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(148, 138, 84) ' Lightish Brown (Bob Cat - Excavate)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find8), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(77, 197, 71) ' Lightish Green (Bob Cat - Removal of Equipment)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find9), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(51, 153, 51) ' Lightish Green (Bob Cat - Removal of Edging)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find10), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(51, 137, 60) ' Darkish Green (Bob Cat - Removal of Mulch)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find11), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(226, 107, 10) ' Lightish Apricot (Soil)
End With
End If
ElseIf InStr(1, LCase(Cl), LCase(Word2Find12), 1) > 0 Then
Set FoundWordCell = wrkSchedule.Cells(Cl.Row, 1)
If LCase(FoundWordCell.Offset(0, 5)) = Booked And IsDate(FoundWordCell.Offset(0, 10)) Then
Set RangeF = wrkSchedule.Range(wrkSchedule.Cells(Cl.Row, 1), wrkSchedule.Cells(Cl.Row, 13))
With RangeF
.Interior.Color = RGB(255, 255, 102) ' Lightish ??? (Bin Hire)
End With
End If
End If
Next Cl
' Delete code between the hashes if you dont want it
'#############################################
If Nothing Is Cl Then
End
Else
MsgBox "Macro Finished Early ??"
End
End If
'#############################################
End With
End Sub
I need it now to look at Column P:BS to see if =AND($J2>0,$A2="Dial before you Dig",P$1>=$J2,P$1<=$K2) and it will fill in Date Columns as per my attachment
Attachments
Last edited by a moderator: