ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming files (https://www.excelbanter.com/excel-programming/387438-naming-files.html)

Larry

Naming files
 
How would I go about saving a file as the concatenation of B1,C1, and E1 in a
macro

Dave Peterson

Naming files
 
with activeworkbook.worksheets("sheet9999")
.parent.saveas filename:="C:\temp\" & _
.range("B1").value & .range("C1").value & .range("E1").value & ".xls" _
fileformat:=xlworkbooknormal
end with

(untested, watch for typos)

Larry wrote:

How would I go about saving a file as the concatenation of B1,C1, and E1 in a
macro


--

Dave Peterson

Barb Reinhardt

Naming files
 
filename = range(B1).value & range(C1).value & range(E1).value

I'm assuming that the active sheet is the same sheet where these ranges are
stored.

You need to have your save code looking something like this:

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Customer\Desktop\Book1.xls",
FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False


"Larry" wrote:

How would I go about saving a file as the concatenation of B1,C1, and E1 in a
macro


Larry

Naming files
 
Is there a way to use the default path that excell is using? if someone else
used this the macro would have to be changed to work for them

"Larry" wrote:

How would I go about saving a file as the concatenation of B1,C1, and E1 in a
macro


Chip Pearson

Naming files
 
Larry,

CurDir will return the current default path.
ThisWorkbook.Path will return the path of the workbook containing the code.
ActiveWorkbook.Path will return the path of the workbook that is currently
active, which may or may not be the workbook containing the code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting LLC
www.cpearson.com
(email on the web site)


"Larry" wrote in message
...
Is there a way to use the default path that excell is using? if someone
else
used this the macro would have to be changed to work for them

"Larry" wrote:

How would I go about saving a file as the concatenation of B1,C1, and E1
in a
macro




Larry

Naming files
 
This is the code I came up with. It seems to work so I guess that is all I
need. I don't think I need to password it.

With ActiveWorkbook.Worksheets("sheet1")
.Parent.SaveAs Filename:=.Range("B1").Value & .Range("C1"). _
Value & .Range ("E1").Value & ".xls"
End With

Thanks everyone


"Larry" wrote:

How would I go about saving a file as the concatenation of B1,C1, and E1 in a
macro



All times are GMT +1. The time now is 11:46 AM.

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