+ Reply to Thread
Results 1 to 9 of 9

How to create Pivot from Data when you don't know the number of data rows.

  1. #1
    Registered User
    Join Date
    01-23-2024
    Location
    USA
    MS-Off Ver
    Excel V2302
    Posts
    5

    Cool How to create Pivot from Data when you don't know the number of data rows.

    Hi, New here and not very good with Excel Macros. I have a spreadsheet where I am pulling in a file and placing the data in a RAW_Data tab. Then I run another macro that creates the pivot table.
    I added the variable code to the beginning of Pivot macro. I think I have this coded correctly but keep getting error "Run-Time error 1404: Reference isn't valid"
    Can someone help? Thank you.

    Administrator's note: Please take the time to review our rules. There aren't many, and they are all important. Our guidelines recommend code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 01-23-2024 at 09:05 AM. Reason: please use code tags

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,674

    Re: How to create Pivot from Data when you don't know the number of data rows.

    What line causes the error?

    I suggest you attach your actual file so we can run your code. See yellow banner at the top of the page.

    You can select the entire columns for your data, assuming you do not have unrelated data below the relevant data. This way you do not have to keep updating the source range for your pivot table if you add more rows of data.
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,966

    Re: How to create Pivot from Data when you don't know the number of data rows.

    Are you sure Sheet1 is the code name for the RAW_DATA sheet?
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Registered User
    Join Date
    01-23-2024
    Location
    USA
    MS-Off Ver
    Excel V2302
    Posts
    5

    Re: How to create Pivot from Data when you don't know the number of data rows.

    Hi, I added the spreadsheet as an attachment.
    I will also be uploading an example of the data. Thanks
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-23-2024
    Location
    USA
    MS-Off Ver
    Excel V2302
    Posts
    5

    Re: How to create Pivot from Data when you don't know the number of data rows.

    Hi, I couldn't get the raw data, so I attached the completed spreadsheet from the manual way of running macro's. The RAW_DATA sheet contains an example of the data. Hmmm failed to upload... I'll try something else.

  6. #6
    Registered User
    Join Date
    01-23-2024
    Location
    USA
    MS-Off Ver
    Excel V2302
    Posts
    5

    Re: How to create Pivot from Data when you don't know the number of data rows.

    Okay, I changed the Attachment so it includes some of the data in the raw_data tab. (Please disregard my first attachment.)
    Attached Files Attached Files

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,966

    Re: How to create Pivot from Data when you don't know the number of data rows.

    Sheet1 is the START_HERE sheet, so this returns 0:

    Please Login or Register  to view this content.
    and you can't then use column 0 in the source data for the pivot.

  8. #8
    Registered User
    Join Date
    01-23-2024
    Location
    USA
    MS-Off Ver
    Excel V2302
    Posts
    5

    Re: How to create Pivot from Data when you don't know the number of data rows.

    I think I understand. The sheet where the data resides is RAW_DATA. Should I use that name instead of sheet1? I see that you are saying the code is incorrect. I am wondering how to fix it then. Thank you

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,966

    Re: How to create Pivot from Data when you don't know the number of data rows.

    Yes, you should. I would suggest changing the routine to something like this:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 02-13-2021, 07:50 AM
  2. Replies: 1
    Last Post: 12-30-2019, 01:17 PM
  3. Replies: 2
    Last Post: 01-11-2018, 10:10 AM
  4. Replies: 9
    Last Post: 05-18-2017, 08:34 AM
  5. Replies: 0
    Last Post: 03-10-2015, 03:34 PM
  6. How do I create a chart that shows a varying number of rows of data?
    By alexander.small in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-23-2013, 04:29 AM

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