Using a Variable in the Workbooks.Open code

  • Thread starter Thread starter Phatchef24
  • Start date Start date
P

Phatchef24

Hey Ron,

I gave that a shot and I couldn't get it to work. Does the variabl
have to be set as a Range? When I tried it, excel gave me an error o
"inexpected end of statement". I guess the extra " " was throwing i
off
 
You can use a string also

Sub test2()
Dim Myvar As String
Myvar = "yourworkbookname"
Workbooks.Open Filename:="\\Jelle\shareddocs\" & Myvar & ".xls"
End Sub
 

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