Hi All,
I have some files with a lot of sheets and each sheet has different ranges that I am using Conditional Formatting in. It works fine. But every few weeks, I am having to sit down and clean all the extra CFs from the file because after running the macros on those files, the cells with CFs get copied onto other ranges within the same broader range.
Because of this duplication of CFs, the files gets slower and slower in few weeks time.
So, I thought of getting rid of all CFs and instead tried to use VBA to format cells. I have got the following so far.
This is not working and giving me Run Time Mismatch Error 13.
Any help in fixing this would be greatly appreciated.
Thanks
Asad
I have some files with a lot of sheets and each sheet has different ranges that I am using Conditional Formatting in. It works fine. But every few weeks, I am having to sit down and clean all the extra CFs from the file because after running the macros on those files, the cells with CFs get copied onto other ranges within the same broader range.
Because of this duplication of CFs, the files gets slower and slower in few weeks time.
So, I thought of getting rid of all CFs and instead tried to use VBA to format cells. I have got the following so far.
Code:
With Range("D15:Q112")
For Each Ar In .Areas
If Range("B" & Ar.Row) = "Vacant" Then
Range("C" & Ar.Row).Interior.Color = RGB(0, 0, 0)
Else
Select Case Ar
Case "OFF"
Ar.Interior.Color = xlNone
Ar.Font.Color = RGB(255, 0, 0)
Ar.Font.Bold = True
Case "Leave"
Ar.Interior.Color = RGB(51, 102, 153)
Ar.Font.Color = RGB(255, 255, 255)
Ar.Font.Bold = False
Case "Relief"
Ar.Interior.Color = RGB(255, 0, 0)
Ar.Font.Color = RGB(255, 255, 255)
Ar.Font.Bold = False
End Select
Select Case Ar.Offset(0, 17)
Case 1
Ar.Interior.Color = RGB(189, 215, 238)
Ar.Font.Color = RGB(0, 0, 0)
Ar.Font.Bold = False
Case 2
Ar.Interior.Color = RGB(246, 123, 0)
Ar.Font.Color = RGB(255, 0, 0)
Ar.Font.Bold = False
Case 3
Ar.Interior.Color = RGB(178, 178, 178)
Ar.Font.Color = RGB(255, 0, 0)
Ar.Font.Bold = False
End Select
End If
Next
End With
This is not working and giving me Run Time Mismatch Error 13.
Any help in fixing this would be greatly appreciated.
Thanks
Asad
Last edited: