ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Formatting via VBA in Excel 2007 (https://www.excelbanter.com/excel-programming/409900-conditional-formatting-via-vba-excel-2007-a.html)

MrWinelover

Conditional Formatting via VBA in Excel 2007
 
New since version 2007 of Excel is the posibility to have conditional
formatting based on cells with specific text beginning with some predifined
text.
This is done by selecting Conditional Formatting (Home tab) Manage
rules... Select "New Rule..." in the "Conditional Formatting Rules Manager"
window. In the "Newt Formatting Rule" windows choose the rule type "Format
only cell that contain" and edit the rule description by choosing "Specific
Text" in the left drop-dowm box and "beginning with" in the right drop-down
box. Give the text to check on in the textfield and click "OK"

Now the same conditional Formatting should be added via VBA but here's my
problem. It seems there is no information on the internet already.

Can someone help me further?
--
MrWinelover...

Bob Phillips

Conditional Formatting via VBA in Excel 2007
 
With Selection
.FormatConditions.Add Type:=xlTextString, _
String:="apple", _
TextOperator:=xlBeginsWith
.FormatConditions(Selection.FormatConditions.Count ).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"MrWinelover" wrote in message
...
New since version 2007 of Excel is the posibility to have conditional
formatting based on cells with specific text beginning with some
predifined
text.
This is done by selecting Conditional Formatting (Home tab) Manage
rules... Select "New Rule..." in the "Conditional Formatting Rules
Manager"
window. In the "Newt Formatting Rule" windows choose the rule type "Format
only cell that contain" and edit the rule description by choosing
"Specific
Text" in the left drop-dowm box and "beginning with" in the right
drop-down
box. Give the text to check on in the textfield and click "OK"

Now the same conditional Formatting should be added via VBA but here's my
problem. It seems there is no information on the internet already.

Can someone help me further?
--
MrWinelover...




MrWinelover

Conditional Formatting via VBA in Excel 2007
 
Thanks Bob for the quick en working reply
--
MrWinelover...


"Bob Phillips" wrote:

With Selection
.FormatConditions.Add Type:=xlTextString, _
String:="apple", _
TextOperator:=xlBeginsWith
.FormatConditions(Selection.FormatConditions.Count ).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"MrWinelover" wrote in message
...
New since version 2007 of Excel is the posibility to have conditional
formatting based on cells with specific text beginning with some
predifined
text.
This is done by selecting Conditional Formatting (Home tab) Manage
rules... Select "New Rule..." in the "Conditional Formatting Rules
Manager"
window. In the "Newt Formatting Rule" windows choose the rule type "Format
only cell that contain" and edit the rule description by choosing
"Specific
Text" in the left drop-dowm box and "beginning with" in the right
drop-down
box. Give the text to check on in the textfield and click "OK"

Now the same conditional Formatting should be added via VBA but here's my
problem. It seems there is no information on the internet already.

Can someone help me further?
--
MrWinelover...






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

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