Posts by Logit

    Two suggested macros (not tested here) from this resource : https://stackoverflow.com/ques…ba-with-two-email-address


    The first one is listed as an answer that works.




    Second macro :


    Quote

    so far I haven't been able to answer a single question.

    That is where I began as well. Confused ... couldn't identify what a line of code truly did except maybe the infamous "Hello World !" line of code. But perseverance paid off. Asking questions for my own projects ... asking for assistance when I "hit a brick wall". Finally, I began answering the questions of others ... easy questions at first ... tougher questions as time passed by.


    For you and others, learning from a book may be preferable. I learn best by the 'hands on' approach. Jump in with both feet and let's see how all these lines of words make this Excel project actually work.


    You can save yourself lots of money just by "googling" what you are looking for. There are thousands of websites that will teach you for free. Some charge a fee but why pay when you can learn it for free ? And those websites have example code and free downloads as well.


    Just do it !


    ps: I still don't understand everything about Excel and VBA and most likely never will. It is a continual learning process.

    Does this work ?

    A quick check with 'google' ... see if this works for you.




    Redirecting

    You can clear the error first, then call the function. However, this is an unusual thing to do. I'm following to see how you make out.



    Methods

    With Err Object there are two methods that you can also use.

    • Err.Clear: This method clears the error number and error description from VBA’s memory (It’s different from “On Error GoTo -1” as it doesn’t completely reset the error).


    You could use the GoTo command .... or .... you could simply recalll the Function.


    Something like :


    There is nothing in your existing macro to cause the issues you are experiencing.


    Two things I would try ....


    #1: Add another command at the end of your macro, telling Excel to close the first workbook. Redundant I know but ???


    #2: Don't utilize the "Workbook_BeforeClose(Cancel As Boolean)". Create a new macro called "CloseMyWB" or something and

    place all your macro commands in there ... including closing the first workbook.

    The following accomplishes the goal you seek. However, it is not presently edited to match your precise layout.

    By changing only a few specifics in the code you will have your project complete. Or ... use the attached as is.


    Cheers.


    Here are two macros ... one to hide and one to unhide. Change the column indicated in the macro code ...


    Compare the code line by line. I commented out a few lines and corrected the TIME to "00:00:02" where noted.


    I ran the edited code without error and it consistently produce a copy of my desktop 10 times in a row ... whereas

    your original code would error out on the 3rd or 4th attempt.