View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Using a Variable in the Workbooks.Open code

Try something like this

Sub test()
Dim Myvar As Range
Set Myvar = Sheets("sheet1").Range("A1")
Workbooks.Open Filename:="\\Jelle\shareddocs\" & Myvar & ".xls"
End Sub


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


"Phatchef24" wrote in message ...

I was wondering if it was possible to use a variable when using the Open
workbook code. I already have the file name that I need declared as a
variable in my code already and now all I need to do is place that name
at the end of this code.

Workbooks.Open
Filename:="\\C:\myfiles\SOMEFILENAMETHATCHANGESeac hmonth.xls"

Is it possible to have excel do this automatically or am I stuck with
having to go in to VBA and edit the code each month?


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