Activating open file with variable

kenman

Board Regular
Joined
Jan 27, 2005
Messages
85
Got a little carried away with last post. Quick question this time.

Have an open file running a macro that goes through other open files one by one. If a file has certain criteria, I am 'activating' the file with the macro and pasting info I have in variables into it. I now want to get back to the file I got the info from so that I can close it and move on to the next file in the group. It seems as when I try and get back to the data file it gets hung up on the fact that there aren't any "Quotes" around the activation file (see below for code I've tried...)
1) Is there an easier way to 'toggle' back to the data file so that I can close it? or
2) the file name is in the file itself..can I assign that to a variable and then append it to the file name and activate it that way?

Show you what I have

Windows("Main.xls").Activate
LR = Cells(65536, 1).End(xlUp).Row
Cells(LR, 1) = "Good"
Cells(LR, 2) = Name
Windows(Name & ".XLS").Activate

Now I know the line below works, but I can't figure out how to get quotes before Name in the last line above..Assume ABCD is the Name variable above

Windows("ABCD.XLS").Activate
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Datsmart,

Thanks for the help. I modified your code and it seems to work fine..Really appreciate the help..
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,736
Members
448,988
Latest member
BB_Unlv

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