Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 59
Default Rank Error in Pivot Table

I have a pivot table set up where you can select a time period and a
geography from a drop down list. The first two columns of my report rank
items by dollar by the geography dollars(column E) and the geographies
competitors dollars(column M). If I change the geogrphy's using the drop
down the data changes and the Rank columns work fine. When I change the time
period, my rank columns do not work and just displays a #DIV/0! The remaning
columns all update accordingly, just the rank columns don't work. Formula
used in the rank columns are below.

=IF(C10<"",RANK(E10,$E$10:$E$2000),"")
=IF(C10<"",RANK(M10,$M$10:$M$2000),"")


Any idea as to why it would work when changing the time period?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Rank Error in Pivot Table

Hi,

You need VB for that and this assumes the colours are a result of shading
and not conditional formats which is much more difficult. ALT+F11 to open VB
editor. Right click 'ThisWorkbook' and insert module and paste the code below
in,

call with

=SumByColor(A1:A29,B1)

Where A1:A29 is the range to sum abnd B1 is shaded with the colour you want
to sum


Function SumByColor(Rng As Range, ClrRange As Range) As Double
Dim c As Range, TempSum As Double, ColorIndex As Integer
Application.Volatile
ColorIndex = ClrRange.Interior.ColorIndex
TempSum = 0
On Error Resume Next
For Each c In Rng.Cells
If c.Interior.ColorIndex = ColorIndex Then
TempSum = TempSum + c.Value
End If
Next c
On Error GoTo 0
Set c = Nothing
SumByColor = TempSum
End Function

Mike


"Supe" wrote:

I have a pivot table set up where you can select a time period and a
geography from a drop down list. The first two columns of my report rank
items by dollar by the geography dollars(column E) and the geographies
competitors dollars(column M). If I change the geogrphy's using the drop
down the data changes and the Rank columns work fine. When I change the time
period, my rank columns do not work and just displays a #DIV/0! The remaning
columns all update accordingly, just the rank columns don't work. Formula
used in the rank columns are below.

=IF(C10<"",RANK(E10,$E$10:$E$2000),"")
=IF(C10<"",RANK(M10,$M$10:$M$2000),"")


Any idea as to why it would work when changing the time period?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 59
Default Rank Error in Pivot Table

Mike,

Think you may have responded to the wrong question. My issue had nothing to
do with colors. Was a error in a ranking formula in a pivot table.


"Mike H" wrote:

Hi,

You need VB for that and this assumes the colours are a result of shading
and not conditional formats which is much more difficult. ALT+F11 to open VB
editor. Right click 'ThisWorkbook' and insert module and paste the code below
in,

call with

=SumByColor(A1:A29,B1)

Where A1:A29 is the range to sum abnd B1 is shaded with the colour you want
to sum


Function SumByColor(Rng As Range, ClrRange As Range) As Double
Dim c As Range, TempSum As Double, ColorIndex As Integer
Application.Volatile
ColorIndex = ClrRange.Interior.ColorIndex
TempSum = 0
On Error Resume Next
For Each c In Rng.Cells
If c.Interior.ColorIndex = ColorIndex Then
TempSum = TempSum + c.Value
End If
Next c
On Error GoTo 0
Set c = Nothing
SumByColor = TempSum
End Function

Mike


"Supe" wrote:

I have a pivot table set up where you can select a time period and a
geography from a drop down list. The first two columns of my report rank
items by dollar by the geography dollars(column E) and the geographies
competitors dollars(column M). If I change the geogrphy's using the drop
down the data changes and the Rank columns work fine. When I change the time
period, my rank columns do not work and just displays a #DIV/0! The remaning
columns all update accordingly, just the rank columns don't work. Formula
used in the rank columns are below.

=IF(C10<"",RANK(E10,$E$10:$E$2000),"")
=IF(C10<"",RANK(M10,$M$10:$M$2000),"")


Any idea as to why it would work when changing the time period?

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
Rank items in Pivot Table Noel Excel Discussion (Misc queries) 3 January 3rd 09 05:16 AM
Can I do a RANK calculation in a Pivot Table Ken Excel Discussion (Misc queries) 3 April 11th 07 05:34 AM
Rank a quantity column using a pivot table Pete Excel Discussion (Misc queries) 0 March 5th 07 10:44 PM
Rank in Pivot Table Matt Cantando Excel Worksheet Functions 0 February 9th 06 07:04 PM
pivot table - Rank A Lesner Excel Discussion (Misc queries) 4 December 2nd 04 04:53 PM


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