Open File Variables

  • Thread starter Thread starter simoncohen
  • Start date Start date
S

simoncohen

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top