Open File based on filename in cell

T

TOMB

I am using a combo box / Vlookup to populate a cell -say C3- with file name.
I want to use this to open the selected file.

myFile = Selection.FormulaR1C1
Workbooks.Open Filename:=myFile

However, since 'C3' is a Vlookup formula, the macro tries to open a file
based on the formula rather than the results of the formula.

Is there a way to have 'myFile' be read as the text of the cell contents?

Thanks

TB
 
O

okrob

I am using a combo box / Vlookup to populate a cell -say C3- with file name.
I want to use this to open the selected file.

myFile = Selection.FormulaR1C1
Workbooks.Open Filename:=myFile

However, since 'C3' is a Vlookup formula, the macro tries to open a file
based on the formula rather than the results of the formula.

Is there a way to have 'myFile' be read as the text of the cell contents?

Thanks

TB

dim myFile as String
myFile = [C3].Value
 
O

okrob

I am using a combo box / Vlookup to populate a cell -say C3- with file name.
I want to use this to open the selected file.

myFile = Selection.FormulaR1C1
Workbooks.Open Filename:=myFile

However, since 'C3' is a Vlookup formula, the macro tries to open a file
based on the formula rather than the results of the formula.

Is there a way to have 'myFile' be read as the text of the cell contents?

Thanks

TB

This works for me regardless of the formula in C3...

myFile = [C3].Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top