#1   Report Post  
Posted to microsoft.public.excel.misc
ynissel
 
Posts: n/a
Default filename in macro

whats the syntax to save a file in a macro but use the file from within a cell
i.e. if cell A1 is the name I want to save the file as - how do I reference
that cell from within the macro?

  #2   Report Post  
Posted to microsoft.public.excel.misc
MartinShort
 
Posts: n/a
Default filename in macro


Try this:


Code:
--------------------
Sub saveFile()
Dim myPath As String
Dim myfileName As String
myPath = "C:\"
myfileName = myPath & Range("A1")
ActiveWorkbook.SaveAs Filename:=myfileName
End Sub
--------------------


Change the variable pathName to suit your needs.

HTH

Martin


--
MartinShort

Software Tester
------------------------------------------------------------------------
MartinShort's Profile: http://www.excelforum.com/member.php...o&userid=22034
View this thread: http://www.excelforum.com/showthread...hreadid=551117

  #3   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default filename in macro

Activeworkbook.SAveAs Filename = Worksheets("Sheet1").Range("A1")

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"ynissel" wrote in message
...
whats the syntax to save a file in a macro but use the file from within a

cell
i.e. if cell A1 is the name I want to save the file as - how do I

reference
that cell from within the macro?



  #4   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default filename in macro

Let's put qwerty.xls in cell A1. Then:

Sub Macro1()
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
End Sub

will do a save_as to your top-level directory.
--
Gary''s Student


"ynissel" wrote:

whats the syntax to save a file in a macro but use the file from within a cell
i.e. if cell A1 is the name I want to save the file as - how do I reference
that cell from within the macro?

  #5   Report Post  
Posted to microsoft.public.excel.misc
ynissel
 
Posts: n/a
Default filename in macro

this is great - thanks! what would the syntax be if the range I want to name
is in a sheet called backup and the cell is A15?
Thanks again.

"Gary''s Student" wrote:

Let's put qwerty.xls in cell A1. Then:

Sub Macro1()
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
End Sub

will do a save_as to your top-level directory.
--
Gary''s Student


"ynissel" wrote:

whats the syntax to save a file in a macro but use the file from within a cell
i.e. if cell A1 is the name I want to save the file as - how do I reference
that cell from within the macro?



  #6   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default filename in macro

Activeworkbook.SAveAs Filename = Worksheets("backup").Range("A15")


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"ynissel" wrote in message
...
this is great - thanks! what would the syntax be if the range I want to

name
is in a sheet called backup and the cell is A15?
Thanks again.

"Gary''s Student" wrote:

Let's put qwerty.xls in cell A1. Then:

Sub Macro1()
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
End Sub

will do a save_as to your top-level directory.
--
Gary''s Student


"ynissel" wrote:

whats the syntax to save a file in a macro but use the file from

within a cell
i.e. if cell A1 is the name I want to save the file as - how do I

reference
that cell from within the macro?



  #7   Report Post  
Posted to microsoft.public.excel.misc
ynissel
 
Posts: n/a
Default filename in macro

What am I doing wrong?
my macro reads:
ChDir "S:\Underwriting\Secondary\Wholesale\WS Rate Sheets"
ActiveWorkbook.SaveAs Filename = Worksheets("Rate Sheet Backup").Range("A31")

Cell A31 reads:
="AFC Wholesale Rate Sheet
"&MONTH(TODAY())&"-"&DAY(TODAY())&"-"&YEAR(TODAY())

and Im getting a file name of false? when the macro runs.
Thanks again,
Yosef

"Bob Phillips" wrote:

Activeworkbook.SAveAs Filename = Worksheets("backup").Range("A15")


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"ynissel" wrote in message
...
this is great - thanks! what would the syntax be if the range I want to

name
is in a sheet called backup and the cell is A15?
Thanks again.

"Gary''s Student" wrote:

Let's put qwerty.xls in cell A1. Then:

Sub Macro1()
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
End Sub

will do a save_as to your top-level directory.
--
Gary''s Student


"ynissel" wrote:

whats the syntax to save a file in a macro but use the file from

within a cell
i.e. if cell A1 is the name I want to save the file as - how do I

reference
that cell from within the macro?




  #8   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default filename in macro

ChDir "S:\Underwriting\Secondary\Wholesale\WS Rate Sheets"
ActiveWorkbook.SaveAs Filename:=Worksheets("Rate Sheet Backup").Range("A31")

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"ynissel" wrote in message
...
What am I doing wrong?
my macro reads:
ChDir "S:\Underwriting\Secondary\Wholesale\WS Rate Sheets"
ActiveWorkbook.SaveAs Filename = Worksheets("Rate Sheet

Backup").Range("A31")

Cell A31 reads:
="AFC Wholesale Rate Sheet
"&MONTH(TODAY())&"-"&DAY(TODAY())&"-"&YEAR(TODAY())

and Im getting a file name of false? when the macro runs.
Thanks again,
Yosef

"Bob Phillips" wrote:

Activeworkbook.SAveAs Filename = Worksheets("backup").Range("A15")


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"ynissel" wrote in message
...
this is great - thanks! what would the syntax be if the range I want

to
name
is in a sheet called backup and the cell is A15?
Thanks again.

"Gary''s Student" wrote:

Let's put qwerty.xls in cell A1. Then:

Sub Macro1()
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
End Sub

will do a save_as to your top-level directory.
--
Gary''s Student


"ynissel" wrote:

whats the syntax to save a file in a macro but use the file from

within a cell
i.e. if cell A1 is the name I want to save the file as - how do I

reference
that cell from within the macro?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
Forcing a macro to pause for filename matpoh Excel Discussion (Misc queries) 3 September 13th 05 06:28 PM
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 06:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"