Hi
I have looked all over and found various threads with similar issues but I cant quite get it to work.
So far my VBA will save a file with a file name as determined by cell "B2" and it saves to the file path "Z:\Documents\Folder 1\Sub folder 2"
However what I want is the file path to not be fixed but to be determined by a Vlookup value that results in Cell "A1".
So in cell "A1" (based on a Vlookup formula that is in it) would return one of the 4 file paths, and which ever filepath it returns I want it to save into the right folder. The file paths will be as below.
"Z:\Documents\Folder 1\Sub folder 1"
"Z:\Documents\Folder 1\Sub folder 2"
"Z:\Documents\Folder 1\Sub folder 3"
"Z:\Documents\Folder 1\Sub folder 4"
and therefore the VBA I want would read the file path in cell A1 and save accordingly. My code so far is
One further issue is that the file path is on a network drive, so presumably some people would have it mapped differently. Could someone explain how I write the file path as a network address (I remember reading a post that gets the file path as a series of numbers but I cant seem to find that post any more.
Many thanks
I have looked all over and found various threads with similar issues but I cant quite get it to work.
So far my VBA will save a file with a file name as determined by cell "B2" and it saves to the file path "Z:\Documents\Folder 1\Sub folder 2"
However what I want is the file path to not be fixed but to be determined by a Vlookup value that results in Cell "A1".
So in cell "A1" (based on a Vlookup formula that is in it) would return one of the 4 file paths, and which ever filepath it returns I want it to save into the right folder. The file paths will be as below.
"Z:\Documents\Folder 1\Sub folder 1"
"Z:\Documents\Folder 1\Sub folder 2"
"Z:\Documents\Folder 1\Sub folder 3"
"Z:\Documents\Folder 1\Sub folder 4"
and therefore the VBA I want would read the file path in cell A1 and save accordingly. My code so far is
Code:
Private Sub CommandButton1_Click()
Dim path As String
Dim filename1 As String
path = "Z:\Documents\Folder 1\Sub folder 2\"
filename1 = Range("B2").Text
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=path & filename1 & ".xlsx", FileFormat:=xlOpenXMLWorkbook
Application.DisplayAlerts = True
End Sub
One further issue is that the file path is on a network drive, so presumably some people would have it mapped differently. Could someone explain how I write the file path as a network address (I remember reading a post that gets the file path as a series of numbers but I cant seem to find that post any more.
Many thanks