Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Conditional Formatting from 2007 to 2003

Hello,

I'm having trouble creating conditional formatting that will work in a pivot
that both 2007 and 2003. I understand that in 2007 you can have more than 3
conditions but 2003 only supports 3. Can anyone give me any suggestions.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Conditional Formatting from 2007 to 2003

The 'classic' way of simulating more than 3 conditions in pre-2007 versions
of Excel is to let VBA (a macro) deal with the formatting. Usually the macro
is triggered by some event, such as a change in a cell on a worksheet or even
selecting the worksheet. But the code I'm providing below will let you
choose when to update the format of the cells in a pivot table.

To try it out: open your workbook, press [Alt]+[F11] to get into the VB
Editor. Choose Insert -- Module and copy and paste the code below into the
module presented. Change the name of the worksheet and range of cells to use
in the code. To test it, run it from the [Developer] tab in Excel 2007 or
using Tools -- Macro -- Macros in pre-2007.

Sub SimulateCFormatting()
'for assistance with this code:
'remove spaces & send email & workbook to
'Help From @ JLatham Site. com

Dim ptWorksheet As Worksheet
Dim formatArea As Range
Dim anyCell As Range

'change to name of sheet with Pivot Table on it
Set ptWorksheet = ThisWorkbook.Worksheets("Pivot Tables")
'change to address of cells to be formatted
Set formatArea = ptWorksheet.Range("B5:B21")
'examine each cell within formatArea and
'format it based on its value
'improve performance
Application.ScreenUpdating = False
For Each anyCell In formatArea
'ignore if cell is empty or if
'the cell displays an error condition
If Not IsEmpty(anyCell) And _
Not IsError(anyCell) Then
'reset from any previous condition
With anyCell
.Font.ColorIndex = xlAutomatic
.Interior.ColorIndex = xlAutomatic
End With
Select Case anyCell.Value
Case Is < 25
'set shading to red, font to bold white
anyCell.Interior.ColorIndex = 3 'red
anyCell.Font.ColorIndex = 2 ' white
anyCell.Font.Bold = True
'you can discover other color values
'and settings by simply recording macros
'while you format the cells as you want them
'and examining the recorded macro code.
'or see Dave McRichie's color page:
'http://www.mvps.org/dmcritchie/excel/colors.htm
Case Is < 50
anyCell.Font.ColorIndex = 3 ' red text
Case Is < 75
anyCell.Font.ColorIndex = 6 ' yellow
'hard to see on white background, so
anyCell.Interior.ColorIndex = 1 ' black
Case Else
'value is 75 or greater
'green cell, white text
anyCell.Interior.ColorIndex = 10 ' green
anyCell.Font.ColorIndex = 2 ' white
anyCell.Font.Bold = True
End Select
End If ' end test for empty/error
Next ' end of anyCell loop
'good housekeeping
Set formatArea = Nothing
Set ptWorksheet = Nothing
End Sub



"blmiller2002" wrote:

Hello,

I'm having trouble creating conditional formatting that will work in a pivot
that both 2007 and 2003. I understand that in 2007 you can have more than 3
conditions but 2003 only supports 3. Can anyone give me any suggestions.

Thanks

.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Conditional Formatting from 2007 to 2003

J,

I appreciate your help, this looks like exactly what we need. One more
question, the people who are going to be looking at this report might find
the need to add or subtract fields from the pivot. Do you know of a way to
insert this formatting into the sheet and give it the functionally to be able
to keep the formatting if things are re-arranged?

Thanks

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/201004/1

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Conditional Formatting from 2007 to 2003

If the pivot table(s) is/are on a sheet separate from the data, it's fairly
easy - we'd move the code into that sheet's _Activate() event processor, then
it would update the format when the sheet is selected.

The problem becomes during the adding/deleting of fields in the PT, and
having the range to look at hard coded. Let me play around some and see if I
can't come up with something.

If we knew that the PT was always going to start on the same row, that would
help, and if we could simply reset the formatting of the entire column to
xlAutomatic, that would make it almost a piece of cake.


"blmiller2002 via OfficeKB.com" wrote:

J,

I appreciate your help, this looks like exactly what we need. One more
question, the people who are going to be looking at this report might find
the need to add or subtract fields from the pivot. Do you know of a way to
insert this formatting into the sheet and give it the functionally to be able
to keep the formatting if things are re-arranged?

Thanks

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/201004/1

.

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
Redundant Conditional Formatting In Move From 2003 to 2007 KMH Excel Discussion (Misc queries) 0 November 19th 09 07:32 PM
Excel 2007 Conditional formatting not refreshing as it did in 2003 Elardus Excel Discussion (Misc queries) 1 September 24th 09 09:14 PM
Conditional Formatting - 2003 to 2007 Richard MG Excel Discussion (Misc queries) 4 March 4th 09 12:14 AM
Sending 2007 files to 2003 users--conditional formatting Bliss Excel Discussion (Misc queries) 2 June 28th 08 09:49 AM
Conditional Formatting: Excel 2003 vs. 2007 JP Excel Worksheet Functions 3 January 13th 07 11:33 PM


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