Hi There.
I am trying to write some VBA code to conditionally format some cells/rows and that will apply across my whole workbook except 2 sheets (sheet 1 & 2) and that will automatically update when things are changed.
They are the results of formulas in the cells.
I know I can use normal conditional formatting but I am working with power query tables and every time the data changes, sometimes it doesn't pick up the formatting.
I have started writing some code below but keep getting "Type Mismatch" errors and cant make it automatically run
Can anyone please have a look and see what I am missing here?
Thank you!
I am trying to write some VBA code to conditionally format some cells/rows and that will apply across my whole workbook except 2 sheets (sheet 1 & 2) and that will automatically update when things are changed.
They are the results of formulas in the cells.
I know I can use normal conditional formatting but I am working with power query tables and every time the data changes, sometimes it doesn't pick up the formatting.
I have started writing some code below but keep getting "Type Mismatch" errors and cant make it automatically run
Can anyone please have a look and see what I am missing here?
Thank you!
Private Sub FOrmatting()
Dim MyRange As Range
Set MyRange = ActiveSheet.Range("A1:V75")
For Each cell In MyRange
If cell.Value = "Early" Then
cell.Interior.Color = RGB(255, 0, 0)
End If
If cell.Value = "Late" Then
cell.Interior.Color = RGB(255, 0, 0)
End If
If cell.Value = "ERROR" Then
cell.Interior.Color = RGB(255, 0, 0)
End If
If cell.Value = "YES - MANUAL PROCESS" Then
cell.Interior.Color = RGB(255, 0, 0)
End If
If cell.Value = "In Booking Time" Then
cell.Interior.Color = RGB(146, 208, 80)
End If
If cell.Value = "TRUE" Then
cell.Interior.Color = RGB(146, 208, 80)
End If
If cell.Value = "NO - AUTO CALCULATION" Then
cell.Interior.Color = RGB(146, 208, 80)
End If
If cell.Value = "NO" Then
cell.Interior.Color = RGB(146, 208, 80)
End If
If cell.Value = "Acceptably Early" Then
cell.Interior.Color = RGB(255, 217, 102)
End If
If cell.Value = "Acceptably Late" Then
cell.Interior.Color = RGB(255, 217, 102)
End If
If cell.Value = "YES" Then
cell.Interior.Color = RGB(255, 217, 102)
End If
If cell.Value = "Journey started and ended in a Business zone" Then
Rows(cell.Row).Interior.Color = RGB(242, 242, 242)
End If
If cell.Value = "**Jane Doe**" Then
Rows(cell.Row).Interior.Color = RGB(242, 242, 242)
End If
If Cell(cell.row "L").Value = "Base (Business)" Then
cell(cell.D).Interior.Color = RGB(255, 204, 204)
cell(cell.F).Interior.Color = RGB(255, 204, 204)
End If
If Cell(cell. row "K").Value = "Base (Business)" Then
cell(cell.D).Interior.Color = RGB(219, 246, 214)
cell(cell.F).Interior.Color = RGB(219, 246, 214)
End If
Next cell
End Sub