+ Reply to Thread
Results 1 to 13 of 13

Restore data after running a specific macro

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Restore data after running a specific macro

    Hello everybody
    I have this code
    Please Login or Register  to view this content.
    The macro called (ClearRange) to clear the range A1:C10 >>
    The macro called CloseMe have to restore data after 10 seconds

    When I run CloseMe I encountered an error messgage (Excel has stopped working) .. Check online for a solution....
    What is the problem with the code?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Restore data after running a specific macro

    I get an error with the SaveChanges.

    What type of variable is this, what value does it have and what do you expect to happen?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Restore data after running a specific macro

    The macro is simlilar to Undo .. i want to undo the clearcontents code by running the macro CloseMe .. not to save the changes!

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Restore data after running a specific macro

    It's not clear to me how you expect this to work unless you keep a copy of what you started with somewhere and then reinstate it when you close the workbook.

    But why are you changing something and then re-instating it?

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Restore data after running a specific macro

    OK I fixed it ..
    Please Login or Register  to view this content.
    The idea is that the user will use a button to restore the data if he has made some mistakes .. He will click the button named (Restore) to restore data and to close the wb for him. that's all

    Now Is it possible to add a line which opens the same wb again?

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Restore data after running a specific macro

    how about:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Restore data after running a specific macro

    thanks Mr. Kaper
    I tested but it seems impossible to open the wb after closing it as the line of close is running first so how it can be opened again!

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

    Re: Restore data after running a specific macro

    FYI, your original code works fine for me, as I would expect, so I suspect something else is interfering. What is the purpose of the Savechanges variable?
    Remember what the dormouse said
    Feed your head

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Restore data after running a specific macro

    The purpose is not to save the last changes by putting the value False for it

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

    Re: Restore data after running a specific macro

    But where is it used?

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Restore data after running a specific macro

    Hi,

    Maybe this ?

    Please Login or Register  to view this content.
    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Restore data after running a specific macro

    Hi, Yassir,

    two questions: why wait for 10 seconds to close down? Will your code restore data after the user has saved the workbook either prior to starting the procedure or while waiting for the 10 seconds? I´m afrasid the answer to my last question is no so you should consider different ways to restore (generally store within another sheet or an array and restore from there).

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Restore data after running a specific macro

    Waiting for 10 seconds just to make the user wait.. If it isn't necessary we can get rid of it.
    The most important point is how to close the WB without saving and reopen it again !!
    Or is there a nother way to restore data without helper sheets (arrays are acceptable)

+ 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] running a macro when specific text is entered into a specific cell
    By deek in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-02-2014, 10:05 AM
  2. Running a macro at specific time
    By HelloWorld518 in forum Access Tables & Databases
    Replies: 1
    Last Post: 06-22-2013, 07:38 PM
  3. [SOLVED] Running a macro on specific day and time
    By Freakazoid in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-17-2013, 10:13 AM
  4. Running a macro at a specific time
    By novice2430 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-05-2009, 09:03 PM
  5. Running a macro on a specific time
    By Viktor Ygdorff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2006, 11:10 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