+ Reply to Thread
Results 1 to 2 of 2

Switching between Workbooks

Hybrid View

  1. #1
    Registered User
    Join Date
    04-13-2012
    Location
    Worclaw, Poland
    MS-Off Ver
    Excel 2010
    Posts
    5

    Switching between Workbooks

    HEy GuYs

    I am new to vba and im struggling with switching between two workbooks (book1 and book2)
    The code below does not work for me. May i kindly ask you wer the problem is macro doews not switch to book2
    Book1 is were the macro is stored.
    Book2 is just "other" workbook
    Both files are opened at the time of runnin macro.

    Many thanks in advance
    Regards
    Peter
    Sub SwitchBtween()
    Dim Book1 As ThisWorkbook
    Dim Book2 As Workbook
    Set Book2 = ActiveWorkbook
    Workbook(Book2).Activate
    End Sub

  2. #2
    Forum Contributor
    Join Date
    04-12-2012
    Location
    MD, England
    MS-Off Ver
    Excel 2003
    Posts
    142

    Re: Switching between Workbooks

    voro

    Sub Switch()
    
        Workbooks("Book2.xls").Activate
        MsgBox "This is wbook 2"
        ''' do something
    
    
        ThisWorkbook.Activate
        MsgBox "This is wbook 1"
        ''' do something
    
    End Sub
    hth
    Last edited by gmk; 07-17-2012 at 11:26 AM. Reason: added msgbox to demo

+ 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