+ Reply to Thread
Results 1 to 20 of 20

Macro to Restore Table Cell to Original Formula

  1. #1
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Macro to Restore Table Cell to Original Formula

    I have a macro set up in workbook to restore a table to almost new.

    It removes all the rows but the first one, then deletes the hard data from the first row, leaving the formulas in the rest of the columns.

    I also want it to restore a cell back to it's original formula. Recoding a macro while doing so did not work. I can't plug the formula itself into the macro as it does periodically change.

    Demo workbook attached... please let me know if further clarifications are required!
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,677

    Re: Macro to Restore Table Cell to Original Formula

    this is what your code did:
    Please Login or Register  to view this content.
    ==> clear all value/formula inside table A6:AEn

    Please Login or Register  to view this content.
    ==> A4:X4 is the header. Why delete?

    Please Login or Register  to view this content.
    ==> There is no formula in AE4 before deleting. What to restore?
    Quang PT

  3. #3
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Re: Macro to Restore Table Cell to Original Formula

    ==> A4:X4 is the header. Why delete?
    In the real file it is this; I added a couple of rows to make a button for demo purposes and didn't think about the implications. S/B A6:X6

    There is no formula in AE4 before deleting. What to restore?
    Restore cell AE6 to it's original formula.

    I have no idea what the macro should be for that beyod getting that cell selected. Recoding a macro while doing that step did not work. I can't plug the formula itself into the macro as it does periodically change.
    Attached Images Attached Images
    Last edited by Tamarissa; 05-28-2025 at 12:16 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    Hi,

    check you posted file against you screenshot, something is not OK AE4 is empty(merged with Y4). If you mean AE6 this is only the value "Entered" in. Not a formula?

    BR, Alexandra

  5. #5
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    If you mean AE6, if you press "Restore to Calculated Column Formula" then the formula will be displayed but a lot of references are wrong.
    So we need the sample file with the original formula before we start your code! Then we can put the original formula in the code as string and return it back after your code is done!



    BR, Alexandra

  6. #6
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Re: Macro to Restore Table Cell to Original Formula

    @cysu11: see reply above.

  7. #7
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Re: Macro to Restore Table Cell to Original Formula

    Then we can put the original formula in the code as string and return it back after your code is done!
    As stated: I can't plug the formula itself into the macro as it does periodically change.

  8. #8
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    Quote Originally Posted by Tamarissa View Post
    As stated: I can't plug the formula itself into the macro as it does periodically change.
    I understand, but we can "save" the formula at the start your codes, and when your code is done, formula will be back!

    BR, Alexandra

  9. #9
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    i mean like this:

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Re: Macro to Restore Table Cell to Original Formula

    And what happens every time the formula changes? That sounds like it's still hard coded.

    The end-user of this is an 'Expert' in Excel because they can add and subtract... training them on the use of the real sheet indicates having to update a macro (or even another cell outside the table to update the macro) is beyond the skill level posessed.

  11. #11
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Re: Macro to Restore Table Cell to Original Formula

    Original formula AE6:

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    Once again, you want to use you code to delete rows etc., right?
    When you start the code, we will integrate in you code that the formula is available in AE6, will be saved/wrote in the code, at the end of you code this saved formula will be written back in AE6.

    Sub test()
    1. save formula
    2. your code...
    3. writhe back the formula in AE6
    end sub

    no expert knowledge needed. So you can change your formula every time, as soon as you start the code, recent formula will be saved and write back! Understand?

    BR, Alexandra

  13. #13
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Re: Macro to Restore Table Cell to Original Formula

    Once again, you want to use you code to delete rows etc., right?
    Correct.

    Understand?
    Yes, I understand.

    When you start the code, we will integrate in you code that the formula is available in AE6
    There will not ever be a formula available in AE6 except when resetting the table to prep for the next period. It will be there for possibly half an hour at most, and then changed to 'Entered' for the remaining time.
    By the time this macro is run, it will have been 2 weeks since a formula was seen in this cell. Any changes to the formula made at the begining period will also never be in this cell for very long. It will ALWAYS say "Entered" at the time of running the macro.


    I just want a macro do exactly what is in my screenshot. Run the "Restore to Calulated Column Formula" process.

  14. #14
    Forum Contributor
    Join Date
    10-16-2023
    Location
    Poland
    MS-Off Ver
    Excel 2019 32bit WIN10
    Posts
    142

    Re: Macro to Restore Table Cell to Original Formula

    Check this:
    Please Login or Register  to view this content.

  15. #15
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    Quote Originally Posted by Tamarissa View Post
    There will not ever be a formula available in AE6 except when resetting the table to prep for the next period. It will be there for possibly half an hour at most, and then changed to 'Entered' for the remaining time.
    Hi,

    OK, then we can save the formula before you change the cell to "Entered", at this time is it the correct formula, right?

    BR, Alexandra

  16. #16
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Re: Macro to Restore Table Cell to Original Formula

    @Tajan That cleared out the cell, it did not restore it to the original formula

    @cycu11 Sure... if you can figure out how to save it for 2 weeks, and take into account any changes that might be made to after saving it that original time.

  17. #17
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    Hi,

    no problem, put you original formula which is correct before you enter "ENTERED" in the Cell AE6 and upload your workbook again, then i will show you.

    BR, Alexandra
    Best regards, Alexandra

    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved"

  18. #18
    Forum Contributor
    Join Date
    06-19-2012
    Location
    Canada
    MS-Off Ver
    Mac Office 365
    Posts
    171

    Re: Macro to Restore Table Cell to Original Formula

    Here is the original formula again:

    Please Login or Register  to view this content.
    As it references many other table columns, sheets, tables, etc in the original workbook, I can't add it here properly.

  19. #19
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    Hi,

    OK, tomorrow i will finish it, now my computer already asleep

    BR, Alexandra

  20. #20
    Valued Forum Contributor
    Join Date
    03-05-2025
    Location
    Deutschland
    MS-Off Ver
    MS Office Home & Business 2024
    Posts
    487

    Re: Macro to Restore Table Cell to Original Formula

    Hi,

    see attachment.

    This in Modul of the Sheet Aimsio Master, it means the Cell AE6 is monitored, as soon as you select the cell AE6 the formula is in, will be saved in the Sheet "SaveFormula", as soon as you choose from the dropdown a value in AE6, the code will do nothing more.

    Please Login or Register  to view this content.
    when you click the Button "Reset Table Data", all you rows in your table will be deleted, except the first row, all value will be cleared in the first row, except Y6 to AE6, by this codes:

    Please Login or Register  to view this content.
    and formula in AE6 will be restored from the sheet "SaveFormula"

    I hope you understand what i mean, but you can try it in the attachment. So the formula AE6 in the attachment, is missing a lot of references, as you already wrote, not all sheets are available in this testfile, but in you original file!

    BR, Alexandra
    Attached Files Attached Files

+ 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. [SOLVED] Userform Image: how to restore original pic?
    By superlative in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2019, 11:50 AM
  2. [SOLVED] VBA Macro - prompt confirmation message before editing - restore initial formula if no
    By Carlin_123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-19-2017, 04:16 PM
  3. [SOLVED] How do I restore original Pivot Table data?
    By Andrew C in forum Excel General
    Replies: 8
    Last Post: 12-14-2016, 03:14 AM
  4. [SOLVED] I run a macro which changes attributes of a cell and then cannot restore gridlines
    By joe31623 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-09-2016, 01:10 AM
  5. Restore to original view after mailing a range as attachment to Outlook
    By knevil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2013, 05:41 PM
  6. Replies: 2
    Last Post: 01-08-2013, 09:20 AM
  7. [SOLVED] How do I restore my original excel settings to default?
    By Patsy in forum Excel General
    Replies: 1
    Last Post: 02-13-2005, 10:08 PM

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