Conditional Formatting using VBA Code

  • Thread starter Thread starter andibevan
  • Start date Start date
A

andibevan

The following VBA code creates conditional formatting for the selecte
cell so that if a number is present in cell U2 the selected cell turn
blue:-

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression
Formula1:="=$U2<>"""""
Selection.FormatConditions(1).Interior.ColorIndex = 35

Using the same code / formatting argument how do I specify that I wan
it applied to cell A1 on sheet "Dialog11"?

Any ideas?

And
 
Hi
try
with worksheets("dialog11").range("A1")
..FormatConditions.Delete
..FormatConditions.Add Type:=xlExpression,
Formula1:="=$U2<>"""""
..FormatConditions(1).Interior.ColorIndex = 35
end with
 
Do you want the formatting applied to A1 on Dialog11 or do you want the
formatting to check the condition of Dialog11 on sheet A1?

Also, the formula you show would react if U2 were empty, not contain a
number.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top