ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Formatting using VBA Code (https://www.excelbanter.com/excel-programming/303673-conditional-formatting-using-vba-code.html)

andibevan

Conditional Formatting using VBA Code
 
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

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Conditional Formatting using VBA Code
 
Hi
try
with worksheets("dialog11").range("A1")
..FormatConditions.Delete
..FormatConditions.Add Type:=xlExpression,
Formula1:="=$U2<"""""
..FormatConditions(1).Interior.ColorIndex = 35
end with

--
Regards
Frank Kabel
Frankfurt, Germany


The following VBA code creates conditional formatting for the

selected
cell so that if a number is present in cell U2 the selected cell

turns
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

want
it applied to cell A1 on sheet "Dialog11"?

Any ideas?

Andi


---
Message posted from http://www.ExcelForum.com/



Tom Ogilvy

Conditional Formatting using VBA Code
 
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.
--
Regards,
Tom Ogilvy

"andibevan " wrote in message
...
The following VBA code creates conditional formatting for the selected
cell so that if a number is present in cell U2 the selected cell turns
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 want
it applied to cell A1 on sheet "Dialog11"?

Any ideas?

Andi


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 09:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com