Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default conditional formatting in excel vba

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 F22, 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:="=F20"
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default conditional formatting in excel vba

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.

" 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 F22, 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:="=F20"
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Conditional Formatting brewster56 Excel Discussion (Misc queries) 1 February 13th 09 05:09 PM
Excel Conditional Formatting brewster56 Excel Discussion (Misc queries) 1 February 13th 09 05:09 PM
conditional formatting in excel Pritchett Excel Worksheet Functions 3 March 27th 06 11:37 AM
Conditional Formatting in Excel Help Please..... Willie T Excel Discussion (Misc queries) 4 February 9th 05 02:28 PM
Excel VBA - Conditional formatting cata_and[_3_] Excel Programming 2 June 4th 04 01:21 PM


All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"