ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditianl formating with AND formula (https://www.excelbanter.com/excel-programming/450664-conditianl-formating-formula.html)

[email protected]

Conditianl formating with AND formula
 
Hello,

I'm trying to format a column (Range("g1:g7")) based on the value of each row in that column AND the value of the same row in another column

Range("g1:g7").Select
aa = "EMEA"
bb = "South Africa"
daformula = "and($g1=aa,$e1=bb)"
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=daformula
Selection.FormatConditions(Selection.FormatConditi ons.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -1638844
.TintAndShade = 0
End With

I've tried the above but does not work

Any advise?

Thanks
Avi

Claus Busch

Conditianl formating with AND formula
 
Hi Avi,

Am Mon, 16 Feb 2015 02:42:19 -0800 (PST) schrieb
:

I'm trying to format a column (Range("g1:g7")) based on the value of each row in that column AND the value of the same row in another column


try:

Sub Test()
Dim aa As String, bb As String, daformula As String

aa = "EMEA"
bb = "South Africa"
daformula = "=AND($g1=""" & aa & """,$e1=""" & bb & """)"

Range("G1:G7").Select
With Selection
.FormatConditions.Add Type:=xlExpression, Formula1:=daformula
.FormatConditions(.FormatConditions.Count).SetFirs tPriority
With .FormatConditions(1).Font
.Color = -1638844
End With
End With
End Sub



Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional

Claus Busch

Conditianl formating with AND formula
 
Hi,

Am Mon, 16 Feb 2015 12:00:31 +0100 schrieb Claus Busch:

aa = "EMEA"
bb = "South Africa"
daformula = "=AND($g1=""" & aa & """,$e1=""" & bb & """)"


or try it this way:

aa = """EMEA"""
bb = """South Africa"""
daformula = "=AND($g1=" & aa & ",$e1=" & bb & ")"


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional

[email protected]

Conditianl formating with AND formula
 
Works fine

Thanks


All times are GMT +1. The time now is 03:18 AM.

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