![]() |
Using a Variable in the Workbooks.Open code
I was wondering if it was possible to use a variable when using the Ope workbook code. I already have the file name that I need declared as variable in my code already and now all I need to do is place that nam at the end of this code. Workbooks.Ope Filename:="\\C:\myfiles\SOMEFILENAMETHATCHANGESeac hmonth.xls" Is it possible to have excel do this automatically or am I stuck wit having to go in to VBA and edit the code each month -- Phatchef2 ----------------------------------------------------------------------- Phatchef24's Profile: http://www.excelforum.com/member.php...fo&userid=1093 View this thread: http://www.excelforum.com/showthread.php?threadid=27504 |
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 |
All times are GMT +1. The time now is 07:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com