+ Reply to Thread
Results 1 to 3 of 3

Selecting an active worksheet AND an active table that keep changing names!

  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Selecting an active worksheet AND an active table that keep changing names!

    In a project I am working on I import a sheet with a pivot table from another workbook.

    I then select a "Grand Total" cell and "explode" it, which creates a new sheet with all the raw data on it.

    I need to work with that.

    At first from a recorded macro it was:

    Please Login or Register  to view this content.
    And I now have tweaked it to:

    Please Login or Register  to view this content.
    which got me past 1) The fact that every time I import a revised pivot table in and expand it, "Sheet1" gets a brand new incremental "Sheet<x>" name given to it ("Sheet1", "Sheet2","Sheet3",...) and got me past the first Table2 reference that was in there, but I believe that second one - the one that is in Range("Table2[PersonName]") is causing me to crash with:

    Run-time error '1004':
    Method 'Range' of object '_Global' failed

    I am creating by trial and error, so please do not presume I know what I am doing!

    It will be followed by:

    Please Login or Register  to view this content.
    So if you see anywhere where I might run into another train wreck, please warn me!

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Selecting an active worksheet AND an active table that keep changing names!

    Why instead of a table you just use ranges? That would be a good idea. So instead of :

    Please Login or Register  to view this content.

    Something like this
    Please Login or Register  to view this content.

    I cannot help you more because I canno see your sheet. But try this. The code asumes your data is in column "B" and starts in row 1.

    Please Login or Register  to view this content.
    Thanks

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Selecting an active worksheet AND an active table that keep changing names!

    This could work (not tested). Assumes the headers in the tables (PersonName and TestDate) are consistent from sheet to sheet.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ 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. Delete nearly all defined names from the active worksheet only
    By kjjjjshab in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2013, 08:39 PM
  2. Get number of rows in a active worksheet in a active workbook
    By tamahome90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-26-2012, 09:06 AM
  3. Macro to edit active chart on active worksheet
    By shlurpee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-07-2011, 04:58 AM
  4. Replies: 0
    Last Post: 02-16-2011, 03:25 AM
  5. [SOLVED] Selecting an Excel tab, Delete Worksheet command is not active
    By missyjes in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 09-23-2005, 11:05 AM

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