+ Reply to Thread
Results 1 to 16 of 16

VBA Pivot Table with Fixed Rows

  1. #1
    Registered User
    Join Date
    05-28-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    19

    Question VBA Pivot Table with Fixed Rows

    Hi,

    This is my first post. I have been stuck with this for some time. I am trying to create a pivot table with fixed rows but it was not possible. The reason for doing this is that sometimes I get data without certain row labels and I do not want the rows to go missing.

    Data (monday)
    Apple---1
    Apple---1
    Pear----1

    Data (tuesday)
    Apple---1
    Orange-1
    Pear----1


    The pivot table I want to achieve ( for monday):

    Fruit----Count
    Apple-----2
    Pear -----1
    Orange----0

    Even though the count for orange is 0, I want to still see it in the table. Is there any way to do this?
    Last edited by excelnewbie80; 05-28-2012 at 05:20 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Pivot Table with Fixed Rows

    Firstly, you cannot add a row into a pivot table manually, even if its via VBA.

    Also, i just did a dummy pivot using your data above and i can see orange in the pivot. I used fruit as the row label (you can even use as a column label) and count in the values field.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-28-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: VBA Pivot Table with Fixed Rows

    Hi, thanks for your reply. I think you misunderstood my question. I am trying to fix the row "orange" so that I can see it even when my data does not have "orange". I have edited my question to better explain the problem.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Pivot Table with Fixed Rows

    As far as i know, the pivot only reflects what entries you have in your data.

    Are you trying to show "orange" in the pivot, so that you can then use it for other analysis using the getpivotdata function?

  5. #5
    Registered User
    Join Date
    05-28-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: VBA Pivot Table with Fixed Rows

    No, I am not using getpivotdata function. My pivot table is based on "Sheet1" and the values in "Sheet1" changes daily. Sometimes, it may have "orange", sometimes it does not have. I have having trouble trying to fix the rows so that I can see all the row labels even though they do not have any data attached to it.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Pivot Table with Fixed Rows

    I can suggest something - You can have the pivot in sheet1 and keep refreshing it as your data gets updated. However, you can also have a rolling report in another sheet in the same workbook which will add in any new row labels that keep getting added to your pivot.

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Table with Fixed Rows

    I would use functions instead of a pivot table - SUMIF and so on - assuming you have a fixed list of items to show.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  8. #8
    Registered User
    Join Date
    05-28-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: VBA Pivot Table with Fixed Rows

    Quote Originally Posted by arlu1201 View Post
    I can suggest something - You can have the pivot in sheet1 and keep refreshing it as your data gets updated. However, you can also have a rolling report in another sheet in the same workbook which will add in any new row labels that keep getting added to your pivot.
    What do you mean by adding new row labels that keep adding to my pivot? I thought you mentioned I cant manually add new row labels? Do you mean I add empty data? - like Orange --0 in my data?

  9. #9
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Pivot Table with Fixed Rows

    The PivotTable won't show an item label if it's not in your source data, so I think that's exactly what arlu is saying: if it isn't there, make sure it gets added to your source data so even when you have 0 oranges you will still see the label because you have an empty row called orange in your source data.
    .?*??)
    `?.???.?*??)?.?*?)
    (?.?? (?.?
    Pichingualas <---
    ??????????????????????????

    Wrap your code with CODE TAGS.
    Thank those who helped you, Don't forget to add to their REPUTATION!!! (click on the star below their post).
    Please mark your threads as [SOLVED] when they are (Thread Tools->Mark thread as Solved).

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Pivot Table with Fixed Rows

    You can put labels in your data and show the value as 0 so that it shows up in your pivot. Or you can have a small macro that checks for any new row labels and adds them to a report. Whichever is easy for you.

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Table with Fixed Rows

    you can set the pivot table up initially with a row for every item then replace that data with your actual data and the old items will remain there.

  12. #12
    Registered User
    Join Date
    05-28-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: VBA Pivot Table with Fixed Rows

    Thanks for all your help. Joseph that's a great idea

  13. #13
    Registered User
    Join Date
    02-15-2005
    Posts
    14

    Re: VBA Pivot Table with Fixed Rows

    Dear Joseph,

    May I know how to set up "you can set the pivot table up initially with a row for every item then replace that data with your actual data and the old items will remain there. "? as mentioned earlier?

    Tac

  14. #14
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Table with Fixed Rows

    I mean that you create dummy rows of data for each item you want and then after refreshing the pivot table you delete those rows. you also need to set that field in the pivot table to display items with no data

  15. #15
    Registered User
    Join Date
    02-15-2005
    Posts
    14

    Re: VBA Pivot Table with Fixed Rows

    I have more 100 items and 10 different criteria to will create at least 1000 possibilities, may I know is there other way to create 1000 rows of dummy data in a faster way rather than creating it manually one by one?

  16. #16
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Table with Fixed Rows

    you do not need to enter every combination of items-just make sure that every item you want appears at least once in the data. honestly I don't know why you would always want 100 items to appear in a pivot table which is supposed to be a summary of your data

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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