Using VBA, I want to conditionally format rows A to G if there is any value in B.
I thought it might be easy, but not for me. I can record a macro to format rows A to G, but don't really know how to do the "applies to" part.
Thank you
Using VBA, I want to conditionally format rows A to G if there is any value in B.
I thought it might be easy, but not for me. I can record a macro to format rows A to G, but don't really know how to do the "applies to" part.
Thank you
Try this...
![]()
Range("A1").Select With Columns("A:G") .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="=$B1<>""""" .FormatConditions(1).Interior.ColorIndex = 36 'Yellow End With
Surround your VBA code with CODE tags e.g.;
[CODE]your VBA code here[/CODE]
The # button in the forum editor will apply CODE tags around your selected text.
You make it look so obvious.
I have a couple questions:
Why Range ("A1"). Select?
Why the four quotes (two sets)?
You're welcome.
In this case, it could have selected any cell in row one. The column B row in this CF formula ("=$B1<>""""") is relative to active cell. As a test, select a different row to see what happens to the CF formulas.
The CF formula in VBA is a string surrounded by two quotes; "=$B1<>"""""
To represent one literal quote within a string in VBA, use two quotes. The formula needed two literal quotes. Thus four quotes in VBA.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks