Return what level cell in pivot table is

cogswel__cogs

Board Regular
Joined
Jan 3, 2018
Messages
168
I have a macro that references a pivottable for results. However since both fields sometimes might have same name I cannot tell by name if I am in first field or second field. When I hover over the cell it tells me the field being reported. Is there some way in vba to know the level/field that the row of the cell I am grabbing data from is?
I ussually just use classic pivot format to resolve but I love to figure out way to not rely on that format.

Any helps greeatly appreciated.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
You can't have two fields in a pivot table with the same name, so I'm not really clear what the issue is. Could you elaborate please?
 
Upvote 0
No not the field the results in the field.

So say I have a manager named Lewis.
Manager field says Lewis
But also Sales rep might say Lewis.

So when I reference the pivot data cell in a macro - The field could be refering to the Manager or the Sales person.
But I cannot tell which row without visually seeing, is there a way to know in VBA if that row is a manager row or sub-field sales person row. You can tell visually by the indention or hovering over.
 
Upvote 0
I think you'd need to give an example of the code you are using and what you want as the result.
 
Upvote 0
I am not using code right now. I am trying to write it now.
 

Attachments

  • zz2.png
    zz2.png
    89.7 KB · Views: 3
Upvote 0
Sorry for the itty bitty picture, above.
I think this might explain better and I really apologize for not being able to explain it more clearly.

If I use get pivot to create formula (below) of the cell I am and the cell below it formula knows that it is reporting (PS_Level_Rollup4 or if it is reporting on PS_Level_Rollup_5 or a subtotal PS_Level_Rollup_4. All I am trying to do is know if the row I am in is a PS_Level_Rollup4 or PS_Level_Rollup5 data.

=GETPIVOTDATA("Count of Current_Year_YTD_Month_End_Actual2",$A$7,"PS_Level_2_Rollup","01-Net Operating Surplus/Deficit","PS_Level_4_Rollup","01-Direct
=GETPIVOTDATA("Count of Current_Year_YTD_Month_End_Actual2",$A$7,"PS_Level_2_Rollup","01-Net Operating Surplus/Deficit","PS_Level_4_Rollup","01-Direct Revenues","PS_Level_5_Rollup","01-Faculty Practice Revenues")
 
Upvote 0
All I am trying to do is know if the row I am in is a PS_Level_Rollup4 or PS_Level_Rollup5 data.
What exactly does that mean? Please be specific: where and how do you want the information returned? Are you trying to use it in a formula? Or something else?
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top