+ Reply to Thread
Results 1 to 6 of 6

Pivot Table - How do I count number of columns?

  1. #1
    Vicky
    Guest

    Pivot Table - How do I count number of columns?

    I would like to be able to calculate how many columns are in my pivot table
    report. Is there a tool within PivotTables?
    Thanks

  2. #2
    Registered User
    Join Date
    08-07-2006
    Posts
    1

    Re: PivotTable count number of columns

    Hi Vicky,

    you could try this code:

    Please Login or Register  to view this content.

    Hope this helps

    tg

  3. #3
    Debra Dalgleish
    Guest

    Re: Pivot Table - How do I count number of columns?

    There's no built-in option that will count the columns. You could use
    programming, e.g.:

    Sub ColumnCount
    MsgBox ActiveSheet.PivotTables(1).TableRange2.Columns.Count
    End Sub


    Vicky wrote:
    > I would like to be able to calculate how many columns are in my pivot table
    > report. Is there a tool within PivotTables?
    > Thanks



    --
    Debra Dalgleish
    Contextures
    http://www.contextures.com/tiptech.html


  4. #4
    Vicky
    Guest

    Re: Pivot Table - How do I count number of columns?

    Debra and tg, Thanks. Would the same apply if you were wanting to count the
    number of rows? Do I just replace the word columns with the word rows?
    Thanks again.

    "Debra Dalgleish" wrote:

    > There's no built-in option that will count the columns. You could use
    > programming, e.g.:
    >
    > Sub ColumnCount
    > MsgBox ActiveSheet.PivotTables(1).TableRange2.Columns.Count
    > End Sub
    >
    >
    > Vicky wrote:
    > > I would like to be able to calculate how many columns are in my pivot table
    > > report. Is there a tool within PivotTables?
    > > Thanks

    >
    >
    > --
    > Debra Dalgleish
    > Contextures
    > http://www.contextures.com/tiptech.html
    >
    >


  5. #5
    Debra Dalgleish
    Guest

    Re: Pivot Table - How do I count number of columns?

    Yes, you can replace Columns with Rows. If you use TableRange2, it
    includes the Page area.
    If you use TableRange1, it doesn't include the Page area.

    Vicky wrote:
    > Debra and tg, Thanks. Would the same apply if you were wanting to count the
    > number of rows? Do I just replace the word columns with the word rows?
    > Thanks again.
    >
    > "Debra Dalgleish" wrote:
    >
    >
    >>There's no built-in option that will count the columns. You could use
    >>programming, e.g.:
    >>
    >>Sub ColumnCount
    >>MsgBox ActiveSheet.PivotTables(1).TableRange2.Columns.Count
    >>End Sub
    >>
    >>
    >>Vicky wrote:
    >>
    >>>I would like to be able to calculate how many columns are in my pivot table
    >>>report. Is there a tool within PivotTables?
    >>>Thanks

    >>
    >>
    >>--
    >>Debra Dalgleish
    >>Contextures
    >>http://www.contextures.com/tiptech.html
    >>
    >>

    >



    --
    Debra Dalgleish
    Contextures
    http://www.contextures.com/tiptech.html


  6. #6
    Vicky
    Guest

    Re: Pivot Table - How do I count number of columns?

    Thanks, I am thrilled that I was able to figure out how to get it into VB on
    my own!

    Question - it seems to be counting the field names, grand totals too. Any
    way to count just the items?

    The below yielded a result of 12

    Sum of Order Amount
    Salesperson Total
    Buchanan 68792.25
    Callahan 123032.67
    Davolio 182500.09
    Dodsworth 75048.04
    Fuller 162503.78
    King 116962.99
    Leverling 201196.27
    Peacock 225763.68
    Suyama 72527.63
    Grand Total 1228327.4


    "Debra Dalgleish" wrote:

    > Yes, you can replace Columns with Rows. If you use TableRange2, it
    > includes the Page area.
    > If you use TableRange1, it doesn't include the Page area.
    >
    > Vicky wrote:
    > > Debra and tg, Thanks. Would the same apply if you were wanting to count the
    > > number of rows? Do I just replace the word columns with the word rows?
    > > Thanks again.
    > >
    > > "Debra Dalgleish" wrote:
    > >
    > >
    > >>There's no built-in option that will count the columns. You could use
    > >>programming, e.g.:
    > >>
    > >>Sub ColumnCount
    > >>MsgBox ActiveSheet.PivotTables(1).TableRange2.Columns.Count
    > >>End Sub
    > >>
    > >>
    > >>Vicky wrote:
    > >>
    > >>>I would like to be able to calculate how many columns are in my pivot table
    > >>>report. Is there a tool within PivotTables?
    > >>>Thanks
    > >>
    > >>
    > >>--
    > >>Debra Dalgleish
    > >>Contextures
    > >>http://www.contextures.com/tiptech.html
    > >>
    > >>

    > >

    >
    >
    > --
    > Debra Dalgleish
    > Contextures
    > http://www.contextures.com/tiptech.html
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1