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 9313739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:57:24+00:00 2026-06-19T01:57:24+00:00

In Excel I am writing a macro to move and format data between two

  • 0

In Excel I am writing a macro to move and format data between two files. I begin by opening the first file and running a macro that allows you to choose a file.

I am opening a file using this code:

myFileName= Application.GetOpenFilename(filefilter:=”All Files, .“, Title:=”All Files”)

I then follow it with this code:

Workbooks.Open Filename:=myFileName

Later in the code Module, I would like to copy and past things between this newly opened file and the one I ran the macro from inside. Currently I am having to hard code their names like so:

Windows(“data.xlsx”).Activate

How can I store the name of the newly opened file in a string and how can I get the name of the excel file I am in into a string?

Thanks

  • 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-19T01:57:26+00:00Added an answer on June 19, 2026 at 1:57 am

    Before opening the second workbook assign the name of the current workbook to a variable:

    nameFirstWorkbook = ActiveWorkbook.Name
    

    You already get the name of the second workbook from the open file dialog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a Macro in excel VBA that creates a data validation list
I am writing an excel file from my c# applicaiton that contains data and
I'm writing a VBA macro in Excel that analyzes data from the spreadsheet and
I'm writing a JUnit test for some code that produces an Excel file (which
While writing the excel file is fine I see that really long numbers are
Today is my first day writing Excel macro and I was given a task
I am writing a macro script in 3 steps: read an excel file by
I'm writing an Excel file recovery program with VB.Net that tries to be a
I am writing a macro that will scrub down an excel list. I need
I found a Macro that works great for importing data from text files 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.