LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default sporadic conditional formatting problem

Duuuuudes:

I'm not sure really what to ask here, but I am having a sporadic issue with
conditional formatting on a pivot table. I have the code below that is
applying 3 conditional formats to a pivot table's data. Before these
conditions are applied I have code that is deleting all conditional
formatting on the pivot table because I have this dynamically applying the
formats as the size of the pivot table changes. For some reason when applying
these formats, let's say cell J50 is active, the conditional format formula
for that cell should say =(SUM($H50:J50))<=$D50 according to the code below,
but it might actually be this =(SUM($H27:J27))<=$D27 even though J50 is
active, which is causing havoc on the way the formatting should be. I don't
understand the sporadic nature of the conditional format formula grabbing
what seems to be some random cells for the formula. The other confusing thing
is I can run the code again and it may work perfectly by having the right
cells in the formula, =(SUM($H50:J50))<=$D50. It's almost like some kind of
data needs to be refreshed but I'm not sure what. Can someone shed some light
on this?

Here's the conditional format code:

'turn off grand totals so they are not calculated in conditional formatting
pvt.RowGrand = False
pvt.ColumnGrand = False

'select data body range
pvt.PivotSelect "Sum of Yards to be Cut[all]", xlDataOnly, True

'make cells white that are covered by the available fabric
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=(SUM($H6:H6))<=$D6"
With Selection.FormatConditions(1)
.Interior.ColorIndex = 2
.Font.Bold = False
.Font.ColorIndex = 1
End With

'make cells yellow that are covered by the available fabric with the
addition of an open po
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=(SUM($H6:H6))<=$D6+$E6"
With Selection.FormatConditions(2)
.Interior.ColorIndex = 6
.Font.Bold = True
.Font.ColorIndex = 1
End With

'make cells red that are not covered by the available fabric with the
addition of an open po
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=(SUM($H6:H6))=$D6+$E6"
With Selection.FormatConditions(3)
.Interior.ColorIndex = 30
.Font.Bold = True
.Font.ColorIndex = 2
End With

'turn grand totals back on after formatting
pvt.RowGrand = True
pvt.ColumnGrand = True


 
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
Conditional Formatting Problem mrogozinski Excel Worksheet Functions 8 June 23rd 09 08:46 PM
Conditional Formatting Problem myssieh Excel Discussion (Misc queries) 3 February 15th 08 04:10 PM
Conditional Formatting Problem TxAg Excel Discussion (Misc queries) 2 October 3rd 05 09:51 PM
Conditional Formatting Problem msimpy22 Excel Discussion (Misc queries) 1 March 1st 05 04:17 AM
Sporadic problem with Enabling Macros Chuck Buchanan Excel Programming 3 April 9th 04 02:30 PM


All times are GMT +1. The time now is 06:10 PM.

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

About Us

"It's about Microsoft Excel"