Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba code to open workbooks Rebecca1 Excel Worksheet Functions 3 March 5th 08 05:15 PM
macro or code to open multiple workbooks Duane Reynolds Excel Discussion (Misc queries) 1 March 14th 06 08:18 AM
Visual Basic code available for all open workbooks KristiB Excel Worksheet Functions 5 May 6th 05 08:46 PM
Sharing variable values between open workbooks? Julian Milano[_2_] Excel Programming 0 January 29th 04 01:13 AM
VBA code for looping through open workbooks and worksheets Jamie Martin[_2_] Excel Programming 1 July 24th 03 06:44 PM


All times are GMT +1. The time now is 07:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"