VBA Conditional Formatting Multiple Columns Variable LR

pantlegger

New Member
Joined
Sep 18, 2016
Messages
27
I have run into a hard place with this. Here is the objective of the workbook. It is a sales tracker trend report for all 12 months. Because employees come and go, I use the last imported sheet as the current "roster". Because this is updated by different people, I am trying to make all one macro. The last piece of the puzzle is to get certain columns to conditional format, however, it won't do all the columns. It is only doing the column that corresponds to the last imported sheet.

I am still a beginner with VBA so I don't know where to begin to troubleshoot as theirs no error code and I can't find any help online. Thanks

Here is the code I have so far:

"Dim rg As Range Dim rg1 As Range
Dim rg2 As Range
Dim rg3 As Range
Dim rg4 As Range
Dim rg5 As Range
Dim rg6 As Range
Dim rg7 As Range
Dim rg8 As Range
Dim rg9 As Range
Dim rg10 As Range
Dim rg11 As Range
Dim cond1 As FormatCondition
Set rg = Range("E6", Range("E6").End(xlDown))
Set rg1 = Range("G6", Range("G6").End(xlDown))
Set rg2 = Range("I6", Range("I6").End(xlDown))
Set rg3 = Range("K6", Range("K6").End(xlDown))
Set rg4 = Range("M6", Range("M6").End(xlDown))
Set rg5 = Range("o6", Range("o6").End(xlDown))
Set rg6 = Range("Q6", Range("Q6").End(xlDown))
Set rg7 = Range("S6", Range("S6").End(xlDown))
Set rg8 = Range("U6", Range("U6").End(xlDown))
Set rg9 = Range("W6", Range("W6").End(xlDown))
Set rg10 = Range("Y6", Range("Y6").End(xlDown))
Set rg11 = Range("AA6", Range("AA6").End(xlDown))

rg.FormatConditions.Delete
rg1.FormatConditions.Delete
rg2.FormatConditions.Delete
rg3.FormatConditions.Delete
rg4.FormatConditions.Delete
rg5.FormatConditions.Delete
rg6.FormatConditions.Delete
rg7.FormatConditions.Delete
rg8.FormatConditions.Delete
rg9.FormatConditions.Delete
rg10.FormatConditions.Delete
rg11.FormatConditions.Delete

Set cond1 = rg.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg1.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg2.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg3.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg4.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg5.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg6.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg7.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg8.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg9.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg10.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond1 = rg11.FormatConditions.Add(xlCellValue, xlLess, "=100%")


With cond1
.Interior.Color = vbRed
End With"
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Solved my own problem. Thought I share


"Dim rg As Range Dim rg1 As Range
Dim rg2 As Range
Dim rg3 As Range
Dim rg4 As Range
Dim rg5 As Range
Dim rg6 As Range
Dim rg7 As Range
Dim rg8 As Range
Dim rg9 As Range
Dim rg10 As Range
Dim rg11 As Range
Dim cond1 As FormatCondition
Dim cond2 As FormatCondition
Dim cond3 As FormatCondition
Dim cond4 As FormatCondition
Dim cond5 As FormatCondition
Dim cond6 As FormatCondition
Dim cond7 As FormatCondition
Dim cond8 As FormatCondition
Dim cond9 As FormatCondition
Dim cond10 As FormatCondition
Dim cond11 As FormatCondition
Dim cond12 As FormatCondition
Set rg = Range("E6", Range("E6").End(xlDown))
Set rg1 = Range("G6", Range("G6").End(xlDown))
Set rg2 = Range("I6", Range("I6").End(xlDown))
Set rg3 = Range("K6", Range("K6").End(xlDown))
Set rg4 = Range("M6", Range("M6").End(xlDown))
Set rg5 = Range("o6", Range("o6").End(xlDown))
Set rg6 = Range("Q6", Range("Q6").End(xlDown))
Set rg7 = Range("S6", Range("S6").End(xlDown))
Set rg8 = Range("U6", Range("U6").End(xlDown))
Set rg9 = Range("W6", Range("W6").End(xlDown))
Set rg10 = Range("Y6", Range("Y6").End(xlDown))
Set rg11 = Range("AA6", Range("AA6").End(xlDown))

rg.FormatConditions.Delete
rg1.FormatConditions.Delete
rg2.FormatConditions.Delete
rg3.FormatConditions.Delete
rg4.FormatConditions.Delete
rg5.FormatConditions.Delete
rg6.FormatConditions.Delete
rg7.FormatConditions.Delete
rg8.FormatConditions.Delete
rg9.FormatConditions.Delete
rg10.FormatConditions.Delete
rg11.FormatConditions.Delete

Set cond1 = rg.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond2 = rg1.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond3 = rg2.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond4 = rg3.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond5 = rg4.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond6 = rg5.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond7 = rg6.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond8 = rg7.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond9 = rg8.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond10 = rg9.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond11 = rg10.FormatConditions.Add(xlCellValue, xlLess, "=100%")
Set cond12 = rg11.FormatConditions.Add(xlCellValue, xlLess, "=100%")


With cond1
.Interior.Color = vbRed
End With
With cond2
.Interior.Color = vbRed
End With
With cond3
.Interior.Color = vbRed
End With
With cond4
.Interior.Color = vbRed
End With
With cond5
.Interior.Color = vbRed
End With
With cond6
.Interior.Color = vbRed
End With
With cond7
.Interior.Color = vbRed
End With
With cond8
.Interior.Color = vbRed
End With
With cond9
.Interior.Color = vbRed
End With
With cond10
.Interior.Color = vbRed
End With
With cond11
.Interior.Color = vbRed
End With
With cond12
.Interior.Color = vbRed
End With"
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top