+ Reply to Thread
Results 1 to 5 of 5

Switching Between Open Workbooks In VBA

  1. #1
    Forum Contributor
    Join Date
    12-22-2004
    Location
    Kokomo, Indiana
    Posts
    236

    Question Switching Between Open Workbooks In VBA

    I have three workbooks named macroWorkbook, databaseFile and dataFile. All of my programming resides in macroWorkbook. The VBA stuff in macroWorkbook open the two other workbooks. The names of the other two files are databaseFile and dataFile have date suffixes affixed to keep weekly data from crossing. How do I programmatically switch between databaseFile and dataFile? Eventually I want to take the contents of sheet1 in dataFile and place it at the bottom of sheet3 which already has data.

    I thought about opening dataFile > copy the contents of from sheet1 > closing dataFile > open databaseFile > paste. This turns out to be more complicated and so I'm here looking for some assistance.

    I am running Excel 2010 on Windows XP.

    Tony
    Last edited by ajocius; 12-16-2012 at 09:50 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Switching Between Open Workbooks In VBA

    paste here the code you are using for opening the 2 workbooks
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    12-22-2004
    Location
    Kokomo, Indiana
    Posts
    236

    Re: Switching Between Open Workbooks In VBA

    code

    Please Login or Register  to view this content.
    code/

    Edit: For CODE tags use # above or [ CODE ]text[ / CODE ] (without blanks)
    Last edited by zbor; 12-16-2012 at 07:01 AM.

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Switching Between Open Workbooks In VBA

    at the end of this code you have datafile activated, you can activate the first workbook with databaseFile.Activate

  5. #5
    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,197

    Re: Switching Between Open Workbooks In VBA

    Hi, Tony,

    there is absolutely no need to switch between the workbooks for copying values once you referenced them with objects:
    Please Login or Register  to view this content.
    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

+ 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