+ Reply to Thread
Results 1 to 10 of 10

Delete Table and Create New One (Without Breaking Dependent Formulas)

  1. #1
    Forum Contributor
    Join Date
    11-10-2011
    Location
    New York, NY
    MS-Off Ver
    MS Office: Excel 365
    Posts
    163

    Delete Table and Create New One (Without Breaking Dependent Formulas)

    Hi --

    I'm using VBA...
    Is it possible to delete a sheet harboring a formatted table (Table #1), then rename a new table (Table #2) to the same name that Table #1 previously had, without breaking the dependent formulas that were based off of Table #1?

    Once the sheet with Table #1 is deleted, all dependent formulas display a '#REF', which is understandable. But ideally the text of the formula can remain as is, since Table #2 will now have the name of Table #1.

    I'm hoping to do so without having to:
    - use indirect in the dependent formulas
    - temporarily rename table #1, use find/replace for the entire workbook to change the dependent formulas, rename Table #2, find/replace again, then finally delete the Sheet with Table #1

    If this is possible in an efficient way it would be an immense help!

    Thank you!

    -kb

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    Is there a reason you can't simply copy the new data to the old table?
    Rory

  3. #3
    Forum Contributor
    Join Date
    11-10-2011
    Location
    New York, NY
    MS-Off Ver
    MS Office: Excel 365
    Posts
    163

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    That's my contingency, but columns will likely be added/removed over time and i'd rather not have to write code to adjust for all that, since it could compromise integrity of the file and is only a temporary fix. Creating a new table based off of current structure is the ideal route.
    Thank you
    Last edited by AliGW; 12-23-2020 at 03:26 AM. Reason: PLEASE don't quote unnecessarily!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    Are you still using Excel 2010? If not, please update your profile.

    It might be helpful to tell us WHY you need to be able to do this, as there may be a better work flow altogether for your situation.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Contributor
    Join Date
    11-10-2011
    Location
    New York, NY
    MS-Off Ver
    MS Office: Excel 365
    Posts
    163

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    (Updated the Excel version, thank you!)

    I have a file where we have individual sheets for over 50+ clients, each with an identical table (each table is large and holds a mass amount of data).

    To write dynamic formulas off all the complete data, I have a code that stacks all the tables into one master consolidation table.
    Throughout the file, there are then formulas which are dependent on the master consolidation table. Whenever we update client specific data, we reconsolidate. To do so, the code creates a new consolidation, deletes the old one, then renames the new one to the name of the old one so that dependent formulas can remain consistent.

    The issue is that when the code deletes the old table, all the dependent formulas break.
    I tried running w/ manual calculations on, hoping that the formulas won't realize what I'm doing, but they do, and still break.

    Thank you!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    OK - I don't understand why anything needs deleting when you consolidate, nor why thy consolidation table can't be dynamic (e.g. using formulae or PowerQuery).

    Why can't your code simply update an existing table?

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Last edited by AliGW; 12-23-2020 at 03:59 AM.

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    Totally agree with Ali - PQ would seem to be the way to go for what you describe.

  8. #8
    Forum Contributor
    Join Date
    11-10-2011
    Location
    New York, NY
    MS-Off Ver
    MS Office: Excel 365
    Posts
    163

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    Interesting --

    I've never touched PowerQuery before.
    I have some homework to do.

    Is there a specific PQ function that would help me achieve the same aim, so that my research into PQ could be more targeted?

    It's worth noting:
    - clients change
    - columns change
    - rows change
    - each client table has a vast amount of data (and are structurally identical with one another)

    The aim result is to have one master table with all information on it so that I can utilize consistent formulas off of that one data source

    & apologies, but due to the sensitivity of the data, I'm unable to share a sample workbook, and the current one being used is too complex to update with dummy data.

    Thanks again for all your assistance!

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    Show us a sample file and we can better advise. If you want help, you have to be prepared to put yourself out a bit - we are doing so for you for free, don’t forget!

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Delete Table and Create New One (Without Breaking Dependent Formulas)

    Further: a sample workbook with two desensitised employee tabs and one master tab will suffice.

+ 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: 06-04-2018, 06:16 PM
  2. [SOLVED] Create excel table using formulas
    By CC_deallist in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-19-2018, 10:48 AM
  3. Replies: 0
    Last Post: 04-06-2017, 02:56 AM
  4. Breaking Up Long Formulas?
    By NoMotion in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 05-27-2015, 03:36 AM
  5. [SOLVED] Contents of table dependent on the value in a cell (preferably formulas)
    By mdovey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2013, 01:00 PM
  6. Delete cell contents without breaking formulas
    By rmf17 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2012, 02:30 AM
  7. Replies: 1
    Last Post: 04-04-2010, 04:15 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