Results 1 to 2 of 2

Constantly Changing Pivot Table Ranges in a Macro

This is a discussion on Constantly Changing Pivot Table Ranges in a Macro within the Excel Questions forums, part of the Question Forums category; I have a data dump that has a different number of rows each time I run it. I created a ...

  1. #1
    New Member
    Join Date
    Feb 2003
    Location
    Boise
    Posts
    3

    Default

    I have a data dump that has a different number of rows each time I run it. I created a macro to create a pivot table. The first part of the Macro is to go to A1 and highlight all the way to the right then all the way down. Then I create the pivot table.

    The problem is that the pivot table code in the macro hardwrites the columns and rows from the first time that I created the macro. For example, if there were 40 rows when I created the macro, the pivot table in the macro will always grab only 40 rows on future runs, regardless of what has been highlighted (selected) or how many rows there acutally are.

    I would think that there would be a way to replace the hard coded rows and columns in the Pivot Table portion of the macro but I can't figure out what it would be.

    Can you assist? Thnks in advance.

    $Who Is John Galt$

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Austin, Texas USA
    Posts
    11,654

    Default

    On 2003-02-06 15:45, johngalt62 wrote:
    I have a data dump that has a different number of rows each time I run it. I created a macro to create a pivot table. The first part of the Macro is to go to A1 and highlight all the way to the right then all the way down. Then I create the pivot table.

    The problem is that the pivot table code in the macro hardwrites the columns and rows from the first time that I created the macro. For example, if there were 40 rows when I created the macro, the pivot table in the macro will always grab only 40 rows on future runs, regardless of what has been highlighted (selected) or how many rows there acutally are.

    I would think that there would be a way to replace the hard coded rows and columns in the Pivot Table portion of the macro but I can't figure out what it would be.

    Can you assist? Thnks in advance.

    $Who Is John Galt$
    Name the cell range containing your "data dump". The best name to use is 'Database'. Use this name as the data source range for your PivotTable.

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
  •  


DMCA.com