PDA

View Full Version : Open xls file based on text in a specific cell



u25103
03-06-2008, 12:15 AM
Hi
this is my problem

I want to open a xls file based on two diffrent ranges B1 and B2.

Dim a As String
Dim b As String
Dim strFilename As String
a = Range("B1").Value
b = Range("B2").Value
strFilename = "H:\???????\???????" \ "a" & "b"".xls"

Workbooks.Open Filename:=strFilename

But it dosen't work. Is there anyone out there who can :help me??
Thanks

Simon Lloyd
03-06-2008, 12:34 AM
Workbooks.Open("C:\MyFolder\" & range("A1").value & Range("B1"),Valueif you need a space between A1 and B1 then add & " " & between the two.

tstav
03-06-2008, 12:36 AM
strFilename = "H:\???????\???????" \ "a" & "b"".xls"

If you mean "Open an already existing file whose name is a+b" then use

strFileName = "H:\???????\???????\" & a & b & ".xls"