Hi There,
I have some vba code that takes a "sheet" called 'BoAML_EDRCD' from an existing workbook and re-saves just that sheet as a new workbook to a location specified in the sheet. See code below:
So basically because I have put Path = "" , it will save the new workbook into the directory I happen to save the spreadsheet where I am running it from, which currently is what I want.
Then I want to take that filename and add the location to a named range in another sheet which I have the in the code:
ThisWorkbook.Sheets("Sheet1").Range("BoAMLDelReport").Value = wb.FullName
Is there a way to strip the full path name down to just the last folder and filename it's saved in so that is saved to the range?
So instead of getting :
G:\DATA\BACKOFF\SETTLEME\Derivatives\ETD\Fund Launches\ ~ Pending - Test\filename.xlsx
I get just the :
\ ~ Pending - Test\filename.xlsx
Sub CreateBoAMLETDDelegatedReport2()
'This code will copy the "BoAML_EDRCD" sheet and rename/create a New Workbook and save it to the location specified
'in order to be sent to BoAML so they can start the ETD On-Boarding preocess.
'The name of the file can be seen in the sheet in cell B1.
Dim Path As String
Dim filename As String
Dim wb As Workbook
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim FName As Variant
Sheets("BoAML_EDRCD").Copy
Path = ""
'"G:\DATA\BACKOFF\SETTLEME\Derivatives\ETD\Fund Launches\"
'"C:\Users\P3001951\Documents\"
filename = Range("AC2")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xlsx"
For Each wb In Application.Workbooks
ThisWorkbook.Sheets("Sheet1").Range("BoAMLDelReport").Value = wb.FullName
Next
ActiveWorkbook.Close
End Sub
I have some vba code that takes a "sheet" called 'BoAML_EDRCD' from an existing workbook and re-saves just that sheet as a new workbook to a location specified in the sheet. See code below:
So basically because I have put Path = "" , it will save the new workbook into the directory I happen to save the spreadsheet where I am running it from, which currently is what I want.
Then I want to take that filename and add the location to a named range in another sheet which I have the in the code:
ThisWorkbook.Sheets("Sheet1").Range("BoAMLDelReport").Value = wb.FullName
Is there a way to strip the full path name down to just the last folder and filename it's saved in so that is saved to the range?
So instead of getting :
G:\DATA\BACKOFF\SETTLEME\Derivatives\ETD\Fund Launches\ ~ Pending - Test\filename.xlsx
I get just the :
\ ~ Pending - Test\filename.xlsx
Sub CreateBoAMLETDDelegatedReport2()
'This code will copy the "BoAML_EDRCD" sheet and rename/create a New Workbook and save it to the location specified
'in order to be sent to BoAML so they can start the ETD On-Boarding preocess.
'The name of the file can be seen in the sheet in cell B1.
Dim Path As String
Dim filename As String
Dim wb As Workbook
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim FName As Variant
Sheets("BoAML_EDRCD").Copy
Path = ""
'"G:\DATA\BACKOFF\SETTLEME\Derivatives\ETD\Fund Launches\"
'"C:\Users\P3001951\Documents\"
filename = Range("AC2")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xlsx"
For Each wb In Application.Workbooks
ThisWorkbook.Sheets("Sheet1").Range("BoAMLDelReport").Value = wb.FullName
Next
ActiveWorkbook.Close
End Sub