+ Reply to Thread
Results 1 to 15 of 15

Open two workbooks into one excel program, then macro code for button to switch between

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    Shepparton, Australia
    MS-Off Ver
    Excel 2010
    Posts
    23

    Open two workbooks into one excel program, then macro code for button to switch between

    Hi all
    I have two workbooks in a folder that have links between them. (becasue there are just too many sheets for one workbook) I have found that these links only work if both workbooks are open at the one time within the one episode of excel. Currently I am the only person that uses the workbooks so open both and use the view menu tab, switch window button to switch between workbooks.

    This works fine for me but now we are getting some new staff who will all need to use these workbooks and enter data. I know that there will be problems with the links. Even with training I know that there will be issues and I am not always going to be there to sort it out. The other problem is the data will get corrupted and be inacurate.

    What I am hoping to be able to do is to make it that when one of the workbooks is opened that the other one will open in the background regardless of which workbook is opened, thus maintaining the links. The other thing that I was hoping to be able to do is get some assistance with the code for a macro to save in both workbooks to activate with a button at the top of the sheets in both workbook to act like the switch between workbooks button in the view tab, so that you can switch between workbooks with the click of the button at the top of the worksheet that you are working in.

    I am not sure it the is possible but it would be great if someone is able to advise me.

    thanks in advance.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    you can "switch" between workbooks by using the ALT TAB key combo
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    01-24-2013
    Location
    Shepparton, Australia
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Thanks FDibbins, I have just used the ALT TAB as suggested and recorded it as a macro and it works great. I don't tend to use short cut keys much maybe I need to pay more attention to them.
    Do you know about being able to open both workbooks at once?
    Thanks again, Oldboots

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    if both files are linked to each other...in other words the links go both ways, you can do this from either file. If file A has the links, then do it from that file...

    on the ribbon, select the DATA tab, and in the connections tab, click on "edit links". select open source, and it will open the other file

    Hope this helps?

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Or you could also try to use ThisWorkBook Open Event to open the other WorkBook when any one of the two is opened.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    I'd probably suggest you reconsider your workbook design. I don't like links between workbooks if they can be avoided and 'too many sheets' doesn't seem like a good reason but does maybe suggest a flawed design
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  7. #7
    Registered User
    Join Date
    01-24-2013
    Location
    Shepparton, Australia
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hi Winon, thanks for your suggestion it sounds good but I am not familiar with the workbook open event. If you are able to help me with the code that would be a fantastic help. The two workbook file names are “IM Client Data new template.xlsm” & “Client list for all FMP Workers.xlsm”.
    I look forward to your reply,
    Thanks, oldboots

  8. #8
    Registered User
    Join Date
    01-24-2013
    Location
    Shepparton, Australia
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hi JosephP, I do take on board what you mean, unfortunately I will have to keep working with the dinosaur that I have inherited. When I get all the bugs ironed out I will probably get time and have the information I need to develop a new workbook.
    Thanks for your input.
    oldboots

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hello oldboots,

    In your WorkBook “Client list for all FMP Workers.xlsm” post this code in the "ThisWorkBook" Code

    Please Login or Register  to view this content.
    And In your WorkBook "IM Client Data new template.xlsm" post this code in the "ThisWorkBook" Code

    Please Login or Register  to view this content.
    Now, whichever WorkBook you open, the other should open as well.

    Hope that helps.

    Also see the "Please consider" note at the bottom of this post.

  10. #10
    Registered User
    Join Date
    01-24-2013
    Location
    Shepparton, Australia
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hi Winon, thanks for taking the time to assist me with this little problem I have. I have copied and pasted the code as you suggested but I just can't seem to get it to work. I have attached the two workbooks with the code in them. Would you be able to assist me again by having a look and see if I have the formatting of the path correct and if not as I believe can you suggest the correct way.
    Sorry to be a pest I know this is simple but I just seem to get it working for me.
    regards, Oldboots
    Attached Files Attached Files

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hello oldboots,

    Please try the attached WorkBooks now.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    01-24-2013
    Location
    Shepparton, Australia
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hi Winon, Thanks again for your help. I have downloaded the two workbooks that you attached above. I put them into a folder on their own and they don't open each other. They both come up with run time error 1004. It says that the path to the other file can not be found to check the spelling is correct. I have not change one thing in the code, just straight as I downloaded them from you. I have been through the developer tab and been into macro security and allowed all macros and ticked it to trust access to vba. I'm not sure what it is that I am doing wrong. Do you have any thoughts?
    Regards, oldboots
    Last edited by oldboots; 02-13-2013 at 02:38 AM.

  13. #13
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hello oldboots,

    I had trouble logging into this site for almost the whole day.

    In both the WorkBooks go to VBA ThisWorkBook Code and change the line to read as shown in red below.

    With the "Client list for all FMP Workers.xlsm" WorkBook

    Please Login or Register  to view this content.
    Where "D:\" = The Path or Directory and
    "Test\" = The actual Folder Name

    With the "IM Client Data new template.xlsm" WorkBook

    Please Login or Register  to view this content.
    Hope that helps!

  14. #14
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hello oldboots,

    Did you manage to come right?

    Sorry, scrap this. I gather from the Rep you gave me, that you managed to get it all working now!
    Last edited by Winon; 02-14-2013 at 09:33 AM. Reason: Posted this before I saw the "Rep"

  15. #15
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Open two workbooks into one excel program, then macro code for button to switch betwee

    Hello oldboots,

    Glad we got it eventually sorted out for you.

    Thank you for the Rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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