Generate a filename from cell range? Anyone.

F

fail2excel

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.
 
E

Eduardo

Hi,
in a macro
sub save_it()
dim fname
with activeworkbook
fname = .worksheets("sheet1").range("E2").value & ".xls"
..saveas fname
end with
end sub
 
J

Jim Thomlinson

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.
 
C

Charles Garrett

I need to save workorders using customer data.  I'd like to run a macrothat
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top