Need macro to open a variable filename

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a variable filename in a cell. The cell, K6, contains "
concatenate(K4,H4)"
I recorded a macro that opens "filename" using
Workbooks.Open FileName:= "filename"
but the filename is hard coded as the name when the macro was recorded, not
a variable name. How do I get the macro to open the variable filename in K6?
I am not a VB programmer.

I tried Workbooks.Open FileName:= (K6) but either it isn't the right way
to do it or the syntax is bad.
 
Try

Workbooks.Open FileName:= Sheets("Sheet 1").Range("K6").value

Where "Sheet 1" is the tab name of the sheet containing the file name.
 
Thanks, that works. Now I have a similar problem switching between open
worksheets:
Windows ("H33").Activate where H33 is the name of the worksheet we
opened in K6 minus the path.
 

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

Back
Top