ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Make (save) a file by using macro recorder. (https://www.excelbanter.com/excel-programming/442943-make-save-file-using-macro-recorder.html)

Farhan

Make (save) a file by using macro recorder.
 
Hi all,

I am new to macro and using macro recoder to create macro. On one file which
I recieve every week from material department. I need to reformat and create
pivot table. I use macro recorder and everything is working good. However I
need that when my recorded macro end it create a file with the same name with
the date and time it was create. I need every week a new file and I dont want
to replace the one. Please let me know how I can create a new file with the
date and time everyweek when I run my macro. Thanks
--
Farhan

Per Jessen

Make (save) a file by using macro recorder.
 
Hi Farhan

This should do it, just insert your path in the MyPath variable:

Dim MyPath As String
Dim fName As String
MyPath = "C:\Temp\" 'Change to suit
fName = "MyFile_" & Format(Now, "mmddyy_hh:mm")
ActiveWorkbook.SaveAs Filename:=MyPath & fName

Best regards,
Per

"Farhan" skrev i meddelelsen
...
Hi all,

I am new to macro and using macro recoder to create macro. On one file
which
I recieve every week from material department. I need to reformat and
create
pivot table. I use macro recorder and everything is working good. However
I
need that when my recorded macro end it create a file with the same name
with
the date and time it was create. I need every week a new file and I dont
want
to replace the one. Please let me know how I can create a new file with
the
date and time everyweek when I run my macro. Thanks
--
Farhan



Dave Peterson

Make (save) a file by using macro recorder.
 
But don't include the colon in the time portion of the format() argument.

"mmddyy_hh:mm"

I'd use:
"mmddyy_hhmmss"



Per Jessen wrote:

Hi Farhan

This should do it, just insert your path in the MyPath variable:

Dim MyPath As String
Dim fName As String
MyPath = "C:\Temp\" 'Change to suit
fName = "MyFile_" & Format(Now, "mmddyy_hh:mm")
ActiveWorkbook.SaveAs Filename:=MyPath & fName

Best regards,
Per

"Farhan" skrev i meddelelsen
...
Hi all,

I am new to macro and using macro recoder to create macro. On one file
which
I recieve every week from material department. I need to reformat and
create
pivot table. I use macro recorder and everything is working good. However
I
need that when my recorded macro end it create a file with the same name
with
the date and time it was create. I need every week a new file and I dont
want
to replace the one. Please let me know how I can create a new file with
the
date and time everyweek when I run my macro. Thanks
--
Farhan


--

Dave Peterson

Farhan

Make (save) a file by using macro recorder.
 
Thanks friends , I will try it on Monday and let you know.
--
Farhan


"Dave Peterson" wrote:

But don't include the colon in the time portion of the format() argument.

"mmddyy_hh:mm"

I'd use:
"mmddyy_hhmmss"



Per Jessen wrote:

Hi Farhan

This should do it, just insert your path in the MyPath variable:

Dim MyPath As String
Dim fName As String
MyPath = "C:\Temp\" 'Change to suit
fName = "MyFile_" & Format(Now, "mmddyy_hh:mm")
ActiveWorkbook.SaveAs Filename:=MyPath & fName

Best regards,
Per

"Farhan" skrev i meddelelsen
...
Hi all,

I am new to macro and using macro recoder to create macro. On one file
which
I recieve every week from material department. I need to reformat and
create
pivot table. I use macro recorder and everything is working good. However
I
need that when my recorded macro end it create a file with the same name
with
the date and time it was create. I need every week a new file and I dont
want
to replace the one. Please let me know how I can create a new file with
the
date and time everyweek when I run my macro. Thanks
--
Farhan


--

Dave Peterson
.



All times are GMT +1. The time now is 02:23 PM.

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