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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

goldfish

Well-known Member
Joined
Aug 23, 2005
Messages
712
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!
 

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
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.
 

Forum statistics

Threads
1,181,102
Messages
5,928,062
Members
436,586
Latest member
latintxn

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
Top