File Name Variables in Macros

Balfin

Board Regular
Joined
Dec 29, 2005
Messages
119
Hi,

Is there a way to assign a variable to a file name, so that I don't have to type the file name in the code every time I want to switch windows? The filename is quite long and made up of several variables so that it contains the date.

Thanks!
 
Ok.

So, what can I do with something defined as a Workbook. Is there a way I can accomplish the same thing?


Hmm...
Code:
Original.Activate
seems to work.

Thanks!
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Accomplish what 'same thing'?

I've seen the code but I don't quite understand it's purpose.
 
Upvote 0
The code's not finished yet, and changing the active window was to test it.

I get an original file once a week (usually Mondays) that someone else generates the Friday before. I need to break it down into 6 separate files, do a little formatting, add a little bit and email it out to 6 different people. It's not very complicated, but it takes awhile. So I thought it would be a good way to play around and learn a bit about macros.

So I figure at some point I'll need to flip between files to add new data and format and the like. Of course, I might not need to. I don't know very much about VBA.
 
Upvote 0
No you shouldn't need to 'flip' between workbooks.

How exactly are you seperating the data out into the 6 seperate files?
 
Upvote 0
I need to break it down by region (there are 6). Each region has 1-4 cities in it, which are listed in column B.
 
Upvote 0
Are the regions listed anywhere?

What I'm thinking here is that you could easily use advanced filter in code to seperate the data to seperate worksheets/workbooks.
 
Upvote 0
No, they aren't. However, the names of the regions and cities don't change, just the number of each and which rows they are in.

By the way, thanks for taking all this time to help.
 
Upvote 0
Could you post some sample data, perhaps using Colo's HTML Maker?

PS You definitely don't have or could create a list for the cities and their corresponding regions?
 
Upvote 0
I could make a list very easily. I can't actually most the data, a lot of it is considered confidential.
 
Upvote 0
I don't think we want/need to see the 'real' data.

Just post something representative.
 
Upvote 0

Forum statistics

Threads
1,215,884
Messages
6,127,561
Members
449,385
Latest member
KMGLarson

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