+ Reply to Thread
Results 1 to 2 of 2

VBA Code to select content from a pivot table, accounting for when there are no or 1 rows

  1. #1
    Registered User
    Join Date
    04-15-2011
    Location
    Illinois USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    VBA Code to select content from a pivot table, accounting for when there are no or 1 rows

    I'm currently using the following to select data rows that start in a pivot table at cell A7.

    I later paste it, but I'm getting errors when that pivot table has 0 or 1 row in it because then it selects all of the blank rows below the pivot table.

    How do I account for these 0/1 row situations?

    Thanks in advance for any help - the only thing I could find got me to the code shown below. The 0/1 row exception wasn't anything I've seen asked in my google searches.
    • Range("A7", Range("A7").End(xlDown).End(xlToRight)).Select
    • Selection.Copy
    Last edited by Thorxes1; 10-13-2023 at 01:56 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA Code to select content from a pivot table, accounting for when there are no or 1 r

    This sounds like you need a table or a named dynamic range using the offset command.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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: 0
    Last Post: 09-20-2020, 05:03 PM
  2. Replies: 1
    Last Post: 02-01-2018, 01:42 PM
  3. Replies: 1
    Last Post: 08-22-2017, 07:18 AM
  4. Creating a Chart from select columns/rows in a Pivot Table
    By dreamer001 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-23-2015, 03:04 PM
  5. Select Rows in Pivot Table and Hightlight
    By Boo123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-01-2015, 02:21 AM
  6. sum of ranges in pivot table - accounting
    By alfi83 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-19-2015, 06:46 AM
  7. [SOLVED] Select all subtotal rows on Pivot Table
    By Marcotte A in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-12-2012, 01:31 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