Referencing a table outside of the active worksheet.

amiersen

New Member
Joined
Jan 11, 2005
Messages
21
Does someone know a way to do this?:

I want a user to be able to input an excel worksheet path into a textbox (including the table name they will be using), then I want my program to use that textbox value to find the specified worksheet/table and use it in a vlookup formula.

I've been trying to write the path to a worksheet cell and then use that cell in a vlookup formula, but so far I haven't had any success.

Thanks in advance!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473
Welcome to MrEcxel -- care to give a more concrete example?

Path you're feeding it, the code you've got for looking up, etc.
 

amiersen

New Member
Joined
Jan 11, 2005
Messages
21
I have a textbox for someone to type a path in, ex. Z:\Excel\Premium Calculations.xls

I then write the value of the textbox to a cell in a worksheet using VB code
ex. Activecell.offset (1,3) = txtbox1.value

I then want my program to use the path in the cell (Z:\Excel\Premium Calculations.xls) to access a table at that location and find an amount using the vlookup formula
ex. =Vlookup (18, $D$2, 1)
 

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473
amiersen said:
I have a textbox for someone to type a path in, ex. Z:\Excel\Premium Calculations.xls

I then write the value of the textbox to a cell in a worksheet using VB code
ex. Activecell.offset (1,3) = txtbox1.value

I then want my program to use the path in the cell (Z:\Excel\Premium Calculations.xls) to access a table at that location and find an amount using the vlookup formula
ex. =Vlookup (18, $D$2, 1)

You're looking for INDIRECT --

=VLOOKUP(18,INDIRECT(D2),1)

NOTE - You need also to specify a range name in your file/path string, sheet also [ well, usually ].

The file referenced in D2 MUST be open, or INDIRECT will return #REF!
 

Forum statistics

Threads
1,148,525
Messages
5,747,194
Members
424,068
Latest member
Salim khamis

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