Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Conditional Formatting in VBA

hi all,

your help is mostly appreciated on following...

Note: the column D used below is only for example, when executed, the
code loops through each column of selection

...i use Conditional Formatting manually by adding a formula
(=SUM(IF($D$5:$D$9="",0,1))<0) into $D$4 with appropriate setting and
all is well - if either cell D5, D6, D7, D8 and/ or D9 has a value, D4
will be formatted as specified.

however if i use this same method in VBA, D4 is only formatted as
specified if D5 has a value, but D6, D7, D8 and/ or D9 are ignored. -
this is the code i use

Worksheets(sName) _
.Range("A1") _
.Offset(3, iColumn2) _
.FormatConditions.Delete
Worksheets(sName) _
.Range("A1") _
.Offset(3, iColumn2) _
.FormatConditions
.Add
Type:=xlExpression,
Formula1:= "=SUM(IF("
& Worksheets(sName). _
Range("A1").Offset(4,iColumn2).Address &
":"
& Worksheets(sName). _
Range("A1").Offset(8, iColumn2).Address &
"="""",0,1))<0"
Worksheets(sName) _
.Range("A1") _
.Offset(3, iColumn2) _
.FormatConditions(1) _
.Interior _
.Pattern = xlNone
With Worksheets(sName) _
.Range("A1") _
.Offset(3, iColumn2) _
.FormatConditions(1) _
.Font
.Bold = False
.Italic = False
.ColorIndex = xlAutomatic
End With

(the formula line is all one line)

thank you in advance for your help...

...jurgenC!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
How can I convert conditional formatting into explicit formatting? Patrick Harris Excel Discussion (Misc queries) 0 April 9th 09 12:00 AM
Conditional formatting--different formatting depending on cell con Tammy S. Excel Discussion (Misc queries) 3 March 30th 09 08:11 PM
Formatting Conditional Formatting Icon Sets The Rook[_2_] Excel Discussion (Misc queries) 3 March 7th 09 08:48 PM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
Conditional Formatting that will display conditional data BrainFart Excel Worksheet Functions 1 September 13th 05 05:45 PM


All times are GMT +1. The time now is 02:36 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"