Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8515763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:14:14+00:00 2026-06-11T05:14:14+00:00

I have a spreadsheet where in the VBA it goes off opening other spreadsheets

  • 0

I have a spreadsheet where in the VBA it goes off opening other spreadsheets and temporarily setting these to the active worksheet.

However, I have a loop and at the end of the first iteration I need to set the active worksheet to be the original one which started the VBA module. I cannot set a new Workbook object to open the original, because the original is still open in the background and it says its already open.

My problem is that I need to change the active Workbook to the original one, when I never had a workbook object to refer to it???

'Original workbook is active implicitly

'loop begins

'change active workbook to something else


'Need to change back to original workbook here- but don't have a VBA workbook object

'end of loop
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:14:15+00:00Added an answer on June 11, 2026 at 5:14 am

    Use ThisWorkbook which will refer to the original workbook which holds the code.

    Alternatively at code start

    Dim Wb As Workbook
    Set Wb = ActiveWorkbook
    

    sample code that activates all open books before returning to ThisWorkbook

    Sub Test()
    Dim Wb As Workbook
    Dim Wb2 As Workbook
    Set Wb = ThisWorkbook
    For Each Wb2 In Application.Workbooks
        Wb2.Activate
    Next
    Wb.Activate
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a VBA macro in an excel spreadsheet that opens all workbooks
I have a spreadsheet of data I am parsing using openpyxl's iter_rows function. However
I have an Excel spreadsheet that I have exported from some other program. It
I have VBA code in an Excel spreadsheet. It is used to set the
We have a lot of VBA code in spreadsheets and a lot of time
I have the following code for handling userforms on my spreadsheet VBA macros: Option
I have two excel spreadsheets, one contains data on various persons, while the other
I have a VBA function within a spreadsheet which operates on another spreadsheet that
We currently have an Excel spreadsheet containing a large amount of VBA code. The
To clarify. I have 1 spreadsheet I am creating the VBA in. When the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.