ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a Variable in the Workbooks.Open code (https://www.excelbanter.com/excel-programming/315712-using-variable-workbooks-open-code.html)

Phatchef24[_8_]

Using a Variable in the Workbooks.Open code
 

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

--
Phatchef2
-----------------------------------------------------------------------
Phatchef24's Profile: http://www.excelforum.com/member.php...fo&userid=1093
View this thread: http://www.excelforum.com/showthread.php?threadid=27504


Ron de Bruin

Using a Variable in the Workbooks.Open code
 
You can use a string also

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



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Phatchef24" wrote in message ...

Hey Ron,

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


--
Phatchef24
------------------------------------------------------------------------
Phatchef24's Profile: http://www.excelforum.com/member.php...o&userid=10938
View this thread: http://www.excelforum.com/showthread...hreadid=275048





All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com