PC Review


Reply
Thread Tools Rate Thread

conditional formatting in excel vba

 
 
lijia137@gmail.com
Guest
Posts: n/a
 
      17th Dec 2007
I have a workbook with several worksheets, i need to do conditional
formatting to column B on each worksheet, does excel conditional
formatting only take up to 3 conditions? cuz my formular is like: if
E2=Y and F2>2, code B2 in blue; if E2=Y and F2<0, code B2 in red,
basically, cells in column B changes color based on colume E and
Colume F, i was recoding macro while doing the conditional formatting,
here is what i wrote: seems macro can't take the last selection? could
somebody help me? thanks a ton!!!

Sub Macro5_ColorCoding()
'
' Macro5_ColorCodingSat Macro
' '

'
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=E2=Y"
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=F2>0"
With Selection.FormatConditions(2).Font
.Bold = True
.Italic = False
.ColorIndex = 5
End With
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=E2=Y"
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=F2<0"
With Selection.FormatConditions(3).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
End Sub
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      17th Dec 2007
The limit of three conditions refers to the number of diffferent colors each
would be a diffferrent formula (Formula1, formula2, formula3). Ffor each
formula you can have an IF statement with multiple conditions.

"(E-Mail Removed)" wrote:

> I have a workbook with several worksheets, i need to do conditional
> formatting to column B on each worksheet, does excel conditional
> formatting only take up to 3 conditions? cuz my formular is like: if
> E2=Y and F2>2, code B2 in blue; if E2=Y and F2<0, code B2 in red,
> basically, cells in column B changes color based on colume E and
> Colume F, i was recoding macro while doing the conditional formatting,
> here is what i wrote: seems macro can't take the last selection? could
> somebody help me? thanks a ton!!!
>
> Sub Macro5_ColorCoding()
> '
> ' Macro5_ColorCodingSat Macro
> ' '
>
> '
> Range("B2").Select
> Range(Selection, Selection.End(xlDown)).Select
> Selection.FormatConditions.Delete
> Selection.FormatConditions.Add Type:=xlExpression,
> Formula1:="=E2=Y"
> Selection.FormatConditions.Add Type:=xlExpression,
> Formula1:="=F2>0"
> With Selection.FormatConditions(2).Font
> .Bold = True
> .Italic = False
> .ColorIndex = 5
> End With
> Selection.FormatConditions.Add Type:=xlExpression,
> Formula1:="=E2=Y"
> Selection.FormatConditions.Add Type:=xlExpression,
> Formula1:="=F2<0"
> With Selection.FormatConditions(3).Font
> .Bold = True
> .Italic = False
> .ColorIndex = 3
> End With
> End Sub
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel- Conditional Formatting erugg21@hotmail.com Microsoft Excel Worksheet Functions 3 30th Jan 2009 09:16 PM
Saving Excel 2007 conditional formatting in Excel 2003 format fmaccrory@gmail.com Microsoft Excel Misc 0 28th Mar 2008 06:42 AM
conditional formatting in excel =?Utf-8?B?c3BvdGxpZ2h0?= Microsoft Excel New Users 1 29th Jun 2006 11:53 AM
Conditional formatting in Excel sike11 via OfficeKB.com Microsoft Excel New Users 10 29th Jun 2006 10:19 AM
Excel VBA & Conditional Formatting Stefan Microsoft Excel Misc 1 5th Sep 2003 05:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:37 AM.