![]() |
Generate a filename from cell range? Anyone.
I need to save workorders using customer data. I'd like to run a macro that
does this automatically using data from range A2:D2 or E2 (which is a data merge of the previous named cells,A2,B2,C2,D2. I've been on this task for 3 days and I am just not getting it. Any help would be helpfull. Thanks Bill T. |
Generate a filename from cell range? Anyone.
Hi,
in a macro sub save_it() dim fname with activeworkbook fname = .worksheets("sheet1").range("E2").value & ".xls" ..saveas fname end with end sub "fail2excel" wrote: I need to save workorders using customer data. I'd like to run a macro that does this automatically using data from range A2:D2 or E2 (which is a data merge of the previous named cells,A2,B2,C2,D2. I've been on this task for 3 days and I am just not getting it. Any help would be helpfull. Thanks Bill T. |
Generate a filename from cell range? Anyone.
You don't mention anything about the path where you want to save the file.
Here is some code to save the new file in the same spot as the existing file... sub test with thisworkbook .saveas thisworkbook.path & "\" & Sheets("MySheet").Range("E2").value end with end sub Where it says Sheets("MySheet"). Change MySheet to the appropriate tab name. -- HTH... Jim Thomlinson "fail2excel" wrote: I need to save workorders using customer data. I'd like to run a macro that does this automatically using data from range A2:D2 or E2 (which is a data merge of the previous named cells,A2,B2,C2,D2. I've been on this task for 3 days and I am just not getting it. Any help would be helpfull. Thanks Bill T. |
Generate a filename from cell range? Anyone.
On Jul 20, 9:52*am, fail2excel
wrote: I need to save workorders using customer data. *I'd like to run a macro that does this automatically using data from range A2:D2 or E2 (which is a data merge of the previous named cells,A2,B2,C2,D2. I've been on this task for 3 days and I am just not getting it. *Any help would be helpfull. Thanks Bill T. Sub workorder() 'Saves filename as value of (CELL INFORMATION) plus the current date Dim newFile As String, fName As String ' Don't use "/" in date, invalid syntax fName = Range("E2").Value 'Change the date format to whatever you'd like, but make sure it's in quotes newFile = fName & " " & Format$(Date, "mm-dd-yyyy") ' Change the directory and file path to yours and saves file as shipment number, date, and time ActiveWorkbook.SaveAs Filename:="C:\JohnSims\MyFiles\WorkOrders\ " & Range("E2").Value & " - " & Format(Now, "yyyy-mm-dd_hhmmss") End Sub |
All times are GMT +1. The time now is 05:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com