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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macro for saving an SS needed

Status
Not open for further replies.

PPykett

Instructor
Dec 4, 2001
1
GB
Hi

Can anybody help me please

I can't work out how to create the following macro:

I need to be able to save the active workbook using the contents of a cell within the sheet as the name. The sheet changes over time, and I need to be able to save periodically as a new save not an update of a previous one

Any help would be very much appreciated

PPykett
 
If I am understanding you correctly, you wish to periodically save ie using a macro, in a file named in a specified cell.

I like to use named ranges so...
1. Name the cell in which you have the file name (I used "WorkbookName")

2. write the fillowing procedure that enables you to select the proper folder in which you will save you workbook each time.
Code:
Sub SaveIt()
    Dim sFileSaveName As String, sWorkbookName As String
    Const EXCEL_FILE_FILTER = "Excel Files (*.xls), *.xls"
    
    sWorkbookName = Range("WorkbookName").Value
    
    sFileSaveName = Application.GetSaveAsFilename( _
        initialfilename:=sWorkbookName, _
        fileFilter:=EXCEL_FILE_FILTER)
        
    If sFileSaveName <> False Then
        ActiveWorkbook.SaveAs sFileSaveName
    End If
End Sub

skip_metzger@voughtaircraft.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top