Consider i have a data like this
Company Department Size
=================================
HCL BFS 50
HCL Insurance 60
CTS BFS 20
CTS Insurance 30
CTS Healthcare 50

Here, say i want to filter out BFS and find the total of remaining at each company level as shown below
Case 1: 
Company Department Total
CTS Healthcare 50
Insurance 30
CTS Total 80
HCL Insurance 60
HCL Total 60
Grand Total 140
Case 2: 
CTS Healthcare 50
CTS Total 50
Grand Total 50
macro code is tried for the same
For Each V In Set visiblePivot = ActiveSheet.PivotTables("PivotTable2") _
.PivotFields("Company").VisibleItems
str = (str & "," & V)
Next V
MsgBox str
So what do i get as output, when running the macro?
EDIT:
for case 1, i get the output as HCL and CTS
---------------------------
Microsoft Excel
---------------------------
,CTS,HCL
---------------------------
OK
---------------------------
and for case 2, i get the output as HCL and CTS.
---------------------------
Microsoft Excel
---------------------------
,CTS,HCL
---------------------------
OK
---------------------------
So what do i expect as output?
for case 1, i expect the output as HCL and CTS
---------------------------
Microsoft Excel
---------------------------
,CTS,HCL
---------------------------
OK
---------------------------
and for case 2, i expect the output as CTS only.
---------------------------
Microsoft Excel
---------------------------
,CTS
---------------------------
OK
---------------------------
To summarize
Please let me know how to attain using macros the Company names that are visible, when the fields in Department are filtered
Here is the code that i finally used to find the filtered data in a pivot table