+ Reply to Thread
Results 1 to 9 of 9

Getting excel to switch back to a workbook?

  1. #1
    Registered User
    Join Date
    03-05-2006
    Posts
    28

    Question Getting excel to switch back to a workbook?

    Hi I want to be able to use VBA to open a 2nd sheet when the spreadsheet first starts ,with
    Please Login or Register  to view this content.
    then switch back to the original one

    I have
    Please Login or Register  to view this content.
    to get the sheets name but I dont know how to the use this to activate back

    This doesn't work
    Please Login or Register  to view this content.
    The reason not to just put in the actual filename is the name can change and then it would crash out.

    Any Ideas
    Last edited by cuewoz; 04-25-2009 at 12:42 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,202

    Re: Getting excel to switch back to a workbook?

    You don't seem to know whether you are referring to a sheet or a workbook. Your first code opens a workbook, the second line returns the full name of the workbook contining the code. I think you want this
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-05-2006
    Posts
    28

    Re: Getting excel to switch back to a workbook?

    I am sorry, I think you misunderstood
    my code together reads
    Please Login or Register  to view this content.
    to go from 1st workbook, then open 2nd workbook and switch straight back.
    This is as the 1st workbook needs code on a 2nd workbook to function, so to make sure its open at the same time, I am adding this in.
    So the Windows(MyFullName).Activate bit should show the 1st workbook again.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,202

    Re: Getting excel to switch back to a workbook?

    Thisworkbook will activate the workbook that contains the code, I would think that is the first workbook.

  5. #5
    Registered User
    Join Date
    03-05-2006
    Posts
    28

    Re: Getting excel to switch back to a workbook?

    I just tried
    Please Login or Register  to view this content.
    and it doesn't work ,the presents sheet remains open, how should I type it please?

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,202

    Re: Getting excel to switch back to a workbook?

    You haven't copied the code that I gave you
    [ThisWorkBook.Activate[/code]

  7. #7
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Getting excel to switch back to a workbook?

    If you described fully what you are doing you may not need to activate the workbook.

    MAcro code is more efficient if you can avoid selecting & activating books, sheets, cells etc
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  8. #8
    Registered User
    Join Date
    03-05-2006
    Posts
    28

    Re: Getting excel to switch back to a workbook?

    Sorry , that works now.

    The reason I need to activate the other sheet is my manager wants this workbook as a stand alone book which has been verified as working correctly and wouldn't let me copy it into new workbook, so I just need to have both open together.

    Seems to have cracked it now though.
    Thanks

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,202

    Re: Getting excel to switch back to a workbook?

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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