Excel Macro - figure out current file name

joe621

New Member
Joined
Oct 23, 2006
Messages
1
Hi Everybody,

I'm currently trying to teach myself a little vb scripting for a project i'm working on.

I've setup a macro to copy/paste data from one spreadsheet to another.

i have the end user opening a template , enter data, then saving the spreadsheet. I then want them to run this macro to copy certain cells from this sheet to another spreadsheet.

i am trying to figure out how to get the name of the spreadsheet that i'm doing the copying from. since it'll be different every time i cant hard code the file name in the script.

I'm also trying to figure how how to switch "focus" between the 2 spreadsheets so that i can copy from one and paste to the other back and forth.

Thanks Much in Advance,

Joe
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Joe

There are various ways to get a filename depending on what exactly you want to do.

For example, you could allow the user to pick the file using Appplication.GetOpenFileName.

As for switch focus to copy/paste, well you should actually need to.

It's not normally needed to activate/select workbooks/sheets/ranges etc for that sort of thing.
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top