Saving with name and date macro

B

Bobby

Hi i hope someone can help me.
I'm trying to set up a macro to save a work book with the name taken from
cell B5 and the date in B6, but after saving i then i need it to stay on the
original book and not on the newly saved one.
Can anyone help please?
 
S

Simon Lloyd

Without specifying a path this will save in My Documents

Code
-------------------

ActiveWorkbook.SaveCopyAs (ActiveSheet.Range("B5").Value & " - " & Format(ActiveSheet.Range("B6"), "dd - mmm - yy") & ".xls"


-------------------

--
Simon Lloy

Regards
Simon Lloy
'The Code Cage' (http://www.thecodecage.com
 
D

Dave Peterson

Option Explicit
Sub Testme()
Dim myFileName As String
Dim myPath As String
myPath = "C:\somefoldernamehere\"
With ActiveWorkbook.Worksheets("sheet1")
myFileName = .Range("b5").Value _
& "-" _
& Format(.Range("B6").Value, "yyyy-mm-dd") & ".xls"
.Parent.SaveCopyAs Filename:=myFileName
End With
End Sub

This doesn't have any validity checks at all!
 
Top