Hi all,
I am working on a macro to save off a file. We would like to pull a few cells of data from a spreadsheet into the name of the spreadsheet. The start date is in cell B3 on the INPUT tab. How can we pull this into the file name using VBA? I think the dashes will cause a problem so we can use underscore instead of dashes .
For example
Start Date: 02/11/22 ( or 2_11_22)
existing code:
Dim NTCT_EXPENSE_PAYROLL As Workbook
Dim CSV_FILE As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("CSV_FILE") 'Sheet to export as CSV
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False 'Possibly overwrite without asking
wbkExport.SaveAs Filename:="C:\EXPORT\7J1", FileFormat:=xlCSV
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
thank you for your help
Sharon
I am working on a macro to save off a file. We would like to pull a few cells of data from a spreadsheet into the name of the spreadsheet. The start date is in cell B3 on the INPUT tab. How can we pull this into the file name using VBA? I think the dashes will cause a problem so we can use underscore instead of dashes .
For example
Start Date: 02/11/22 ( or 2_11_22)
existing code:
Dim NTCT_EXPENSE_PAYROLL As Workbook
Dim CSV_FILE As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("CSV_FILE") 'Sheet to export as CSV
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False 'Possibly overwrite without asking
wbkExport.SaveAs Filename:="C:\EXPORT\7J1", FileFormat:=xlCSV
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
thank you for your help
Sharon