Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create macro in excel.

Status
Not open for further replies.

mrdavid57

Programmer
May 10, 2001
11
US
How do I create a macro in excel that would save my spreadsheet as one of the cell entries?
 
The following code will save the active file (using all the default settings) into the current directory with whatever name is cell A1. No error trapping has been included for posible invalid filenames.
Code:
Sub SaveFile()
    ActiveWorkbook.SaveAs Filename:=[A1]
End Sub
A.C.
 
This works

Sub nbtest()
'
' nbtest Macro

Dim fname As Range, Fpath As String

Fpath = "c:\my Documents\"
Set fname = Worksheets("Sheet1").Range("A1")


'Save just with cell A1 Remove the ' on the required line

'ActiveWorkbook.SaveAs Filename:=fname

'Saves with Fpath and Cell A1

ActiveWorkbook.SaveAs Filename:=Fpath & fname

End Sub Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top