+ Reply to Thread
Results 1 to 8 of 8

Is activecell in a Table, a Pivot Table, or a data range?

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Is activecell in a Table, a Pivot Table, or a data range?

    Trying to come up what a way to determine what my activecell is in; a Table, a PivotTable, a data range, or a shape. Whatever it's in will determine what my macro does next. I'm not finding much online except https://www.techrepublic.com/blog/mi...is-in-a-table/, which had a function that gave me hope, but doesn't seem to work. Any help would be appreciated.
    I know I'm not stupid, but I suspect I'm a lot stupider than I think I am

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,155

    Re: Is activecell in a Table, a Pivot Table, or a data range?

    Attach a sample xls file with objects to the location of the active cell in them (minimum: 2 x Tables, 2 x PivotTables, 2 x Shapes, 2 x free/normal lists)

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

    Re: Is activecell in a Table, a Pivot Table, or a data range?

    You can use activecell.pivottable or activecell.listobject. I don’t know what you mean by a data range, and cells are never in shapes (they are different layers).
    Remember what the dormouse said
    Feed your head

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Is activecell in a Table, a Pivot Table, or a data range?

    Shape isn't really necessary, I just threw that in. Let me explain more of what I need this more, maybe that will clarify.

    Every morning a new Active Position Report (APR) is created by another team. Approx 15K lines by 185 columns of information. Each day I have to make reports from subsets of the data, and I do that via 3 different macros, but I want to do it with one. Here's why there's 3:

    The APR on some days is just the data residing in cells (Normal Range), plain vanilla. I run my macro, it creates my reports, life is good.
    The APR on some days is in a table format. My second macro converts the Table to a Normal Range then creates my reports.
    The APR on some days in in a pivot. My third macro converts the pivot to values and cleans it up, which results in a Normal Range, then creates my reports.

    So Tables and Pivot's need to be converted first. I can use an inputbox to tell VBA which of the three types it is, but I'd rather have VBA determine that based on the ActiveCell, hence this post.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Is activecell in a Table, a Pivot Table, or a data range?

    I'm part way there, by cheating. The sub below tells me whether the Activesheet has a pivot, or a table, or neither (normal range). I can use this for my immediate need, because only one of the three will exist in my APR, but I'd still like to see if there's a way to determine this from the Activecell.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,265

    Re: Is activecell in a Table, a Pivot Table, or a data range?

    You'd basically just do something like this:

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Is activecell in a Table, a Pivot Table, or a data range?

    Much Better! I tested it as shown below, and it passed with flying colors. Now I can adapt it to my specific need. Thanks so much for helping me with this!
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,155

    Re: Is activecell in a Table, a Pivot Table, or a data range?

    Use 3 "For Each Next" loops dedicated to individual objects ('ListObjects', 'PivotTables', 'Shapes') and 'CurrentRegion' and use the command syntax assigned to the methods and properties of these individual objects and the 'Intersect' method, which will identify the affiliation (or lack thereof) of 'ActiveCell' to the given object. Use such elements as: 'Address', 'Name', 'RangeSelection', 'TopLeftCell', 'BottomRightCell' ... maybe 'Split'.

+ 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: 6
    Last Post: 01-24-2017, 06:56 PM
  2. Automating Pivot table and pivot chart creation if data table names unknown
    By Vegiepie2016 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-04-2016, 11:52 AM
  3. Replies: 5
    Last Post: 01-06-2012, 04:35 PM
  4. Replies: 1
    Last Post: 06-22-2010, 09:10 AM
  5. Replies: 1
    Last Post: 06-20-2010, 04:00 AM
  6. Return pivot table range...not the data table, the PIVOT TABLE!
    By Air_Cooled_Nut in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2008, 01:07 PM
  7. ActiveCell is Query Table or Pivot Table?
    By Air_Cooled_Nut in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-13-2006, 11:07 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