ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Saving with name and date macro (https://www.excelbanter.com/excel-discussion-misc-queries/212064-saving-name-date-macro.html)

Bobby

Saving with name and date macro
 
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?

Simon Lloyd[_39_]

Saving with name and date macro
 

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 Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=35583


Dave Peterson

Saving with name and date macro
 
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!


Bobby wrote:

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?


--

Dave Peterson

Bobby

Saving with name and date macro
 
Thank You for the replies Guys, your help, once again has got me what i
needed.

"Dave Peterson" wrote:

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!


Bobby wrote:

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?


--

Dave Peterson


Simon Lloyd[_58_]

Saving with name and date macro
 

Glad you got what you need, however Dave's is the one to go with really!Bobby;158440 Wrote:
Thank You for the replies Guys, your help, once again has got me what i
needed.

"Dave Peterson" wrote:

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!


Bobby wrote:

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?


--

Dave Peterson



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=35583



All times are GMT +1. The time now is 11:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com