Intersect PivotFields & RowFields

nzo12

New Member
Joined
Mar 16, 2016
Messages
5
What I want it to do is intersect rows "Emp. Name" & "Avg Salary". I can then apply Font.Color filters to specific values down the line, but for now I can't figure out how to select the correct intersects.This is what the pivot looks like.
Values
Row LabelsAvg. SalaryData #1Data #2 Data #3
Manager #175,000
Emp. Name50,000
Emp. Name100,000
Manager #250,000
Emp. Name25,000
Emp. Name75,000

<tbody>
</tbody>
Here is what I have so far but its not working. Essentially, it is applying the Font.Color changes to the entire "Avg Salary" Column instead of only to the "Emp Names" in "Avg Salary".

Code:
Dim rng1 As Range    Dim rng2 As Range
Set rng1 = pvt.PivotFields("Avg Salary").DataRange
Set rng2 = pvt.RowFields("Employees").DataRange.EntireRow
Intersect(rng1, rng2).Font.Color = vbRed
This is what I want the code to do.
Values
Row LabelsAvg. SalaryData #1Data #2Data #3
Manager #175,000
Emp. Name50,000
Emp. Name100,000
Manager #250,000
Emp. Name25,000
Emp. Name75,000

<tbody>
</tbody>

Any help being able to find the correct intersect would be much appreciated.
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

nzo12

New Member
Joined
Mar 16, 2016
Messages
5
I've tried every variation I can find on the web. Is it even possible to do what I'm asking?
 

nzo12

New Member
Joined
Mar 16, 2016
Messages
5
Thank you. I have been using that.

What I found is that this is getting me close.

Set rng1 = pvt.RowFields("Employees").PivotItems("Jon James").DataRange.EntireRow Set rng2 = pvt.PivotFields("Avg Salary").DataRange


Intersect(rng1, rng2).Font.Color = vbRed
This intersects the salary and row field but only for the employee "Jon James." I'm assuming my next step is to create an array using the employee names and pass that arrow into .PivotItems

I'll update the thread if I figure it out. Who knows, it may help someone down the line who is searching for a similar answer.
 

tonyyy

Well-known Member
Joined
Jun 24, 2015
Messages
1,647
Another approach would be to add a column to your source data to differentiate your employees... for example, the column could be labeled Color, and employee attributes could be red, blue, green...

Then your code could be...

Code:
Set rng1 = pvt.RowFields("Color").PivotItems("Red").DataRange.EntireRow
That would eliminate the need for an array.
 

Watch MrExcel Video

Forum statistics

Threads
1,101,892
Messages
5,483,536
Members
407,397
Latest member
HerbA

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top