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

  • SEARCH
  • Home
  • 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 8870287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:41:10+00:00 2026-06-14T17:41:10+00:00

is there any way to write a code (VBA) that it will be able

  • 0

is there any way to write a code (VBA) that it will be able to acknowledge that you open an Unknown Excel File while the macro is running???

My purpose is to copy some values from the Unknown Excel Workbook to the one on the macro which is running, but I am not sure if that is possible.

The idea of the code would be something like that:

Sub test()
    MSG1 = MsgBox("Do you want to copy the values?", vbYesNo, "OPEN")

    If MSG1 = vbYes Then

    MsgBox "Open the file you want to copy"

    'Here is when the user has to open the file and the VBA
    'acknowledge that and keep running the macro but only if the file is open

    ThisWorkbook.Range("A1:B10").Value = _
    Workbooks(Workbooks.Count).Range("A1:B10").Value

    End If
End Sub

Any thoughts.

  • 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-14T17:41:11+00:00Added an answer on June 14, 2026 at 5:41 pm

    I have a better suggestion. Use the Application.GetOpenFilename to make the user select the file and then open that file. That ways the code will know which file is being opened. For example

    Sub test()
        Dim Ret, msg
        Dim wb1 As Workbook, wb2 As Workbook
    
        msg = MsgBox("Do you want to copy the values?", vbYesNo, "OPEN")
    
        If msg = vbYes Then
            Set wb1 = ThisWorkbook
    
            Ret = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*")
    
            If Ret <> False Then
                Set wb2 = Workbooks.Open(Ret)
                wb1.Sheets("Sheet1").Range("A1:B10").Value = _
                wb2.Sheets("Sheet1").Range("A1:B10").Value
            End If
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to write to a text file in Flex 4.6? Its
Is there any other way to write javascript:false that is more pleasant? I'm building
is there any way to config htaccess to write to access-log file which is
If there any way to write short cut code instead of this one I
Is there any way to write a LINQ style short hand code for walking
Is there any way to write error log or exception into a file in
Is there any way to write an integration test to test that the FetchMode.Eager
Is there any way to write a valid header/link/image? Something like <a href=index.html><h1 id=logo>Company
Is there any way to write Shoes application using IDE (NetBeans for example)? I
Is there any way to write binary output to sys.stdout in Python 2.x? In

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.