ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open File Variables (https://www.excelbanter.com/excel-programming/312141-open-file-variables.html)

simoncohen[_6_]

Open File Variables
 

I have some code that opens files "aug04.xls" and similar (i.e. fixe
names). I would like to put the month in say cell a1 on the spreadshee
and for the macro to then open the files named after what is in the cel
a1.

Thank

--
simoncohe
-----------------------------------------------------------------------
simoncohen's Profile: http://www.excelforum.com/member.php...nfo&userid=785
View this thread: http://www.excelforum.com/showthread.php?threadid=26541


Norman Jones

Open File Variables
 
Hi Simon

Try something like:

Sub Atester03()
Dim MyFile As Workbook
Dim sStr As String

sStr = Range("A1").Value & "04"
Set MyFile = Workbooks.Open(sStr)

End Sub

If you have Aug04 entered in the cell, change:

sStr = Range("A1").Value & "04"

to

sStr = Range("A1").Value



---
Regards,
Norman



"simoncohen" wrote in message
...

I have some code that opens files "aug04.xls" and similar (i.e. fixed
names). I would like to put the month in say cell a1 on the spreadsheet
and for the macro to then open the files named after what is in the cell
a1.

Thanks


--
simoncohen
------------------------------------------------------------------------
simoncohen's Profile:
http://www.excelforum.com/member.php...fo&userid=7854
View this thread: http://www.excelforum.com/showthread...hreadid=265410





All times are GMT +1. The time now is 11:52 PM.

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