Multiple conditional formatting with VBA

ballgameaddictus

New Member
Joined
Oct 17, 2008
Messages
11
I don't profess to be an expert with VBA... so I'm asking the experts!

I have a huge spreadsheet and in column B, I have three names that are repeated... for ease of reference I'll call them Ann, Betsy and Charlie.

For each occurance of Ann, I need to highlight the row in gray; for each occurrence of Betsy, I need to format all cells in that row to be currency and for each occurrance of Charlie, I need to change it to number format.

I have tried working with this and I've got the VBA to work - kinda! But once I add my second condition - it over-rides the first.

I've searched and searched for hours now and tried several different things but can't get anything to work.

Please help!!

With Cells.FormatConditions
.Delete
.Add Type:=xlExpression, _
Formula1:="=COUNTIF(R[]:R[],""Ann"")"
.Item(1).Interior.ColorIndex = 15
End With
With Cells.FormatConditions
.Delete
.Add Type:=xlExpression, _
Formula1:="=COUNTIF(R[]:R[],""Betsy"")"
.Item(1).NumberFormat = "$#,##0.00"
End With
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

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