ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filename macro and a little more? (https://www.excelbanter.com/excel-programming/407700-filename-macro-little-more.html)

kennected

Filename macro and a little more?
 
The following works for me:

Sub SaveAuto()
Dim fname
Dim fpath
fpath = "C:\Documents and Settings\Ken\Desktop\"
fname = Format(Now, "MDD_hhmm")
ActiveWorkbook.SaveAs fpath & fname
End Sub

But in addition to the result of the date code, I would like the filename
result to contain a prefix using the contents of a partcular cell of the
original workbook (3 letters that represents a customer code) which would
allow us to sort the files saved by customer in the saved directory.

Can this be done

joel

Filename macro and a little more?
 
Sub SaveAuto()
Dim fname
Dim fpath
Dim Prefix
Prefix = Range("A1")
fpath = "C:\Documents and Settings\Ken\Desktop\"
fname = Format(Now, "MDD_hhmm")
ActiveWorkbook.SaveAs fpath & Prefix & fname
End Sub

"kennected" wrote:

The following works for me:

Sub SaveAuto()
Dim fname
Dim fpath
fpath = "C:\Documents and Settings\Ken\Desktop\"
fname = Format(Now, "MDD_hhmm")
ActiveWorkbook.SaveAs fpath & fname
End Sub

But in addition to the result of the date code, I would like the filename
result to contain a prefix using the contents of a partcular cell of the
original workbook (3 letters that represents a customer code) which would
allow us to sort the files saved by customer in the saved directory.

Can this be done


Ted McCoy

Filename macro and a little more?
 
something like:

Sub SaveAuto()
Dim fname
Dim fpath

Dim fprefix as string
fprefix = sheets("sheetname").cells(rownumber,columnnumber). value
fpath = "C:\Documents and Settings\Ken\Desktop\"
fname = fprefix & "_" & Format(Now, "MDD_hhmm")
ActiveWorkbook.SaveAs fpath & fname
End Sub





"kennected" wrote in message
...
The following works for me:

Sub SaveAuto()
Dim fname
Dim fpath
fpath = "C:\Documents and Settings\Ken\Desktop\"
fname = Format(Now, "MDD_hhmm")
ActiveWorkbook.SaveAs fpath & fname
End Sub

But in addition to the result of the date code, I would like the filename
result to contain a prefix using the contents of a partcular cell of the
original workbook (3 letters that represents a customer code) which would
allow us to sort the files saved by customer in the saved directory.

Can this be done



Dave Peterson

Filename macro and a little more?
 
Yesterday's response didn't work, huh?

kennected wrote:

The following works for me:

Sub SaveAuto()
Dim fname
Dim fpath
fpath = "C:\Documents and Settings\Ken\Desktop\"
fname = Format(Now, "MDD_hhmm")
ActiveWorkbook.SaveAs fpath & fname
End Sub

But in addition to the result of the date code, I would like the filename
result to contain a prefix using the contents of a partcular cell of the
original workbook (3 letters that represents a customer code) which would
allow us to sort the files saved by customer in the saved directory.

Can this be done


--

Dave Peterson

kennected

Filename macro and a little more?
 
You guys are awesome! Thanks a million. Works great. I just wish I had
more time to learn some of this. It took me about 10 years to bet the basics
in formula writing down.
P.S. Sorry Dave, just figured out how to navigate the groups and hadn't
realized you had responded. Didn't get an email the way I thought I would
have.

"kennected" wrote:

The following works for me:

Sub SaveAuto()
Dim fname
Dim fpath
fpath = "C:\Documents and Settings\Ken\Desktop\"
fname = Format(Now, "MDD_hhmm")
ActiveWorkbook.SaveAs fpath & fname
End Sub

But in addition to the result of the date code, I would like the filename
result to contain a prefix using the contents of a partcular cell of the
original workbook (3 letters that represents a customer code) which would
allow us to sort the files saved by customer in the saved directory.

Can this be done



All times are GMT +1. The time now is 01:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com