JonRowland
Active Member
- Joined
- May 9, 2003
- Messages
- 416
- Office Version
- 365
- Platform
- Windows
Hi,
I'm trying to do the folllowing with my VBA code. I want to prompt the user to browse for a file and then hard code the PATH and FileName into that workbook for another procedure that would be used at various times.
At the moment I'm doing this manually. In the code below the variable FileToOpen captures the full path & filename as one. The issue with this, unless anyone can advise different , is that another produced I add an XLOOKUP based on
So the [ & ] is the issue in having a one variable with the path & filename.
So ideally I'd like to tweak the code below to get separate path and filename.
Hope that makes sense.
Thanks
I'm trying to do the folllowing with my VBA code. I want to prompt the user to browse for a file and then hard code the PATH and FileName into that workbook for another procedure that would be used at various times.
At the moment I'm doing this manually. In the code below the variable FileToOpen captures the full path & filename as one. The issue with this, unless anyone can advise different , is that another produced I add an XLOOKUP based on
VBA Code:
Cells(2, 4).FormulaR1C1 = _
"=XLOOKUP(RC[-1],'" & FilePath & "[" & File & "]" & ShtName & "'!C1,'" _
& FilePath & "[" & File & "]" & ShtName & "'!C35,""NOT IN LIST"",FALSE)"
So the [ & ] is the issue in having a one variable with the path & filename.
So ideally I'd like to tweak the code below to get separate path and filename.
VBA Code:
Sub Get_Data_From_File()
Dim FileToOpen As Variant
Dim Path As String
Dim File As String
FileToOpen = Application.GetOpenFilename("Excel Files (*.xls*), *xls*", , "Select File")
If FileToOpen <> False Then
' Here I'd like to hard code the path & filename. FileToOpen get the full path & filename in one string
Path = xxxxxxxx
FileName = xxxxxxxxxxxx
End If
End Sub
Hope that makes sense.
Thanks