Macro to save a file as file name from cell contents


Posted by Sam on February 24, 2001 12:19 PM

I'm stumped on this one. I need a Macro to save my
current file from two cells, lets say cells a1 & a2.I also need in this same macro the ability to save the file to a different location other than the location that the original file is located. And here is the easy one I think. How do I get an accending number into a cell each time the worksheet is opened? Thanks, Sam



Posted by David Hawley on February 24, 2001 3:32 PM


Hi Sam


For your save macro use:

Sub SaveMe()
Dim MyFileName As String
MyFileName = "C:\My Documents\My Pictures\" _
& Sheets("Sheet1").Range("A1") & _
Sheets("Sheet1").Range("A2")

ThisWorkbook.SaveAs FileName:=MyFileName
End Sub


And change the sheet name and path to suit.


For Your increasing number. Right click on the sheet picture with the X on it, top left next to file and select "View Code". Paste in this code.

Private Sub Workbook_Open()
Sheets("Sheet1").Range("A1") = _
1 + Sheets("Sheet1").Range("A1")
End Sub


Change A1 and the sheet name to suit.


Dave


OzGrid Business Applications