Building a filename

  • Thread starter Thread starter cullenb
  • Start date Start date
C

cullenb

Hello
in my code i have the following line

Workbooks.Open Filename:= _
"G:\MyDocuments\excel\abigsheet\bigsheetJan.xls"

on my sheet i have a data validation list containing the months of the year.
I would like to select from this list and have the appropriate workbook
open. However i cannot find the correct method for concatenating the
selection with the filename.

eg
Workbooks.Open Filename:= _
"G:\MyDocuments\excel\abigsheet\bigsheet" +A3 ".xls"

Can anybody tell me what the correct syntax should be?
regards
Barrie
 
Hi
try
Workbooks.Open Filename:= _
"G:\MyDocuments\excel\abigsheet\bigsheet" _
& worksheets("sheet1").range("A3").value _
& ".xls"
 
Try something like....

Workbooks.Open Filename:= "G:\MyDocuments\excel\abigsheet\bigsheet" & A3 & ".xls

Make sure there is a space on either side of the

Martin
 
Thanks for the responses, but still no joy
In both cases it t only returns bigsheet.xls without tagging the month on at
the end.
anymore suggestions are welcome
Barrie
 
You probably need to set up a string variable to capture
the month.

Dim strMonth as string

strMonth = Range("A2")

Workbooks.Open Filename:= _
"G:\MyDocuments\excel\abigsheet\bigsheet" &
strMonth & ".xls"
 
Note if A3 is referring to a cell reference, rather than a variable, either
use range("A3") or put brackets around it, i.e.

Workbooks.Open Filename:= "G:\MyDocuments\excel\abigsheet\bigsheet" & [A3] &
".xls"

Paul D
 
Thanks to all those who responded.
finally have it working using the string variable method from Dmeade and
also
tried it using a suggestion from Paul D which also worked.
once again thanks
Barrie
 

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