Hi hopefully somebody can help. Using Conditional Formatting I've built a workbook which checks for a number in a series of columns on one worksheet and if it finds a it in a grid (named range 'Grid'), formats the cell to a particular colour. This works great, but I have 150 CFs so the whole workbook is very sluggish. What I would like it to replicate the CFs in VBA so that I can then choose when to run (ie it isn't volatile, so isn't processor heavy). My first attempt in VBA looks like this;
The Named range 'Grid' = A5:AX204
Sub Macro1()
'
' Macro1 Macro
'
'
Application.Goto Reference:="Grid"
Application.CutCopyMode = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ISNUMBER(MATCH(A5,WDC!$A:$A,0))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ISNUMBER(MATCH(A5,WDC!$C:$C, 0))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = -0.249946592608417
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Unfortunately this just inserts the original CFs rather than allowing me to choose when to run. I'm terrible with VBA, so hoping that this is an easy-ish answer for somebody.
Any help is greatly appreciated.
The Named range 'Grid' = A5:AX204
Sub Macro1()
'
' Macro1 Macro
'
'
Application.Goto Reference:="Grid"
Application.CutCopyMode = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ISNUMBER(MATCH(A5,WDC!$A:$A,0))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ISNUMBER(MATCH(A5,WDC!$C:$C, 0))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = -0.249946592608417
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Unfortunately this just inserts the original CFs rather than allowing me to choose when to run. I'm terrible with VBA, so hoping that this is an easy-ish answer for somebody.
Any help is greatly appreciated.