Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8781469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:18:36+00:00 2026-06-13T20:18:36+00:00

Consider i have a data like this Company Department Size ================================= HCL BFS 50

  • 0

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

Pivot without any filter

Here, say i want to filter out BFS and find the total of remaining at each company level as shown below

Case 1: Pivot With filter - after removing BFS as the department using filter

 Company    Department  Total
 CTS    Healthcare  50
        Insurance   30
 CTS Total           80
 HCL    Insurance   60
 HCL Total           60
 Grand Total        140

Case 2: Pivot table with only single Company after filtering of the Department

 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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:18:37+00:00Added an answer on June 13, 2026 at 8:18 pm

    Here is the code that i finally used to find the filtered data in a pivot table

    Sub getVisibleFields()
        ' this will return all the rows that are visible in the 
        'pivot table. Even the subtotal rows
        Set visibleCompany = ActiveSheet.PivotTables("PivotTable2") _
                   .PivotFields("Company").DataRange
        For Each V In visibleCompany
            ' different values can be checked to filter out unwanted data
            'to find data like "CTS Total           80"
            If InStrRev(visibleCompany(i + 1), " Total") > 0 Then
                MsgBox ("Total is " & visibleCompany(i + 1)
            End If
            str = (str & "," & V)
        Next V
        MsgBox str
     End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please consider this scenario: I have data like this : Id Group Value -----------------------------------
Consider I have an anchor which looks like this <div class=res> <a href=~/Resumes/Resumes1271354404687.docx> ~/Resumes/Resumes1271354404687.docx
I have a text file as input like this:let say it as xyz.txt TIME
I have a service contract interface that looks like this: [ServiceKnownType(typeof(GeometricModelDescriptor))] [ServiceKnownType(typeof(TemplateModelDescriptor))] [ServiceContract] public
Consider this example data: field1 field2 1 100 2 100 3 101 4 102
Consider a table invoice_data containing data about invoices over 12 years. This data will
I am working on an application that works like this: It fetches data from
I am building an ad analytics tool which assumes a data structure like this:
I have array in which i want to store values like this 1203 char*
I have a large tree-like data structure of objects which behave mostly identical but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.