OPEN/ACTIVATE A FILE WITH VBA USING THE CONTENT OF A CELL

gab

New Member
Joined
Jul 24, 2007
Messages
24
Hiiii!!! I'm almost at the end of a code and I'm facing a problem: I have to open .xls files, and I usually use to open with:

i.e Windows("hedge.xls").Activate

And the file, which is currently opened, is activated.....

but now it's different:

I have the name of the file in a cell and i tried to open as follows:

Windows(Cells(counter, 3)).Activate

And it's not working!!....please, any help i'll appreciate.

P.S by the way,,if it said cells(counter,3) it's because is a list of files need to be activated, and i put the counter to do it
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hello. Try:
Code:
Windows(Cells(counter, 3).value).Activate

HTH,

~Gold Fish

P.S. In the future it can sometimes be helpful to post the error that is displayed, but it wasn't needed this time!
 
Upvote 0
You can try:

Windows(Cells(counter, 3).Value).Activate

Also works:
Workbooks(Cells(counter, 3).Value).Activate

Let me know if this works for you. Cells(Counter, 3) without the value property may be returning a range object for the cell rather than its contents/cell value.

Regards.
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,563
Members
448,972
Latest member
Shantanu2024

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