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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Welcome to MrEcxel -- care to give a more concrete example?

Path you're feeding it, the code you've got for looking up, etc.
 
Upvote 0
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)
 
Upvote 0
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!
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,720
Members
449,050
Latest member
MiguekHeka

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