Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Save function in VB

I have an Excel spreadsheet that contains several tabs which will each be
saved off to the same folder but with different names. The file names will
follow the same naming convention (i.e. YYYY-MM Name of compay - location).

I would like to have the code create the file name for me. This files will
always be created the 2nd day after the month end. I need the date portion
of the file name to be the 4-digit year and the previous 2 digit month. I
would like a message box to be displayed prior to saving each file that will
display the proposed file name. If the name is not correct, I would like the
message box to allow you to change the file name before saving. Is there any
to do this?

--
Hlewis
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Save function in VB

Hi Hlewis

You can use this in the file name for thw month

MsgBox Format(Month(Now) - 1, "mm")


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Hlewis" wrote in message ...
I have an Excel spreadsheet that contains several tabs which will each be
saved off to the same folder but with different names. The file names will
follow the same naming convention (i.e. YYYY-MM Name of compay - location).

I would like to have the code create the file name for me. This files will
always be created the 2nd day after the month end. I need the date portion
of the file name to be the 4-digit year and the previous 2 digit month. I
would like a message box to be displayed prior to saving each file that will
display the proposed file name. If the name is not correct, I would like the
message box to allow you to change the file name before saving. Is there any
to do this?

--
Hlewis



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Save function in VB

Okay. That helps me a little bit. I am going to include the code that I
have so far. I don't know if this will help explain what I am trying to do.
I'm pretty new to VBA so I'm not sure in what order things have to happen or
the correct commands to use. I will practice it though so I won't have to
keep bugging you guys. :-)

Sub MoveCopy()
'
' MoveCopy Macro


'This macro will save the individual sheets into their respective workbooks
and save them to the Obso Need Files
Dim stDate As Date
stDate = Now()



'Co 755 and 764 Southwestern
Sheets(Array("Co 755 Exploded", "Co 764 Exploded")).Select
Sheets("Co 755 Exploded").Activate
Sheets(Array("Co 755 Exploded", "Co 764 Exploded")).Copy
ActiveWorkbook.SaveAs Filename:= _
"T:\Period End Schedules\Inventory Account Schedules\Inventory
Obsolescence\Obso Need Files\2006-02 Obsolescence Files - Heaverneck.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Windows("2006-02 Obsolescence Files.xls").Activate
--
Hlewis


"Ron de Bruin" wrote:

Hi Hlewis

You can use this in the file name for thw month

MsgBox Format(Month(Now) - 1, "mm")


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Hlewis" wrote in message ...
I have an Excel spreadsheet that contains several tabs which will each be
saved off to the same folder but with different names. The file names will
follow the same naming convention (i.e. YYYY-MM Name of compay - location).

I would like to have the code create the file name for me. This files will
always be created the 2nd day after the month end. I need the date portion
of the file name to be the 4-digit year and the previous 2 digit month. I
would like a message box to be displayed prior to saving each file that will
display the proposed file name. If the name is not correct, I would like the
message box to allow you to change the file name before saving. Is there any
to do this?

--
Hlewis




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Save function in VB

OK

Try this

Dim str As String
str = "T:\Period End Schedules\Inventory Account Schedules\Inventory Obsolescence\Obso Need Files\" _
& Format(DateSerial(Year(Date), Month(Date) - 1, Day(Date)), "yyyy-mm") & " Obsolescence Files - Heaverneck.xls"
MsgBox str

You can use this now

ActiveWorkbook.SaveAs str

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Hlewis" wrote in message ...
Okay. That helps me a little bit. I am going to include the code that I
have so far. I don't know if this will help explain what I am trying to do.
I'm pretty new to VBA so I'm not sure in what order things have to happen or
the correct commands to use. I will practice it though so I won't have to
keep bugging you guys. :-)

Sub MoveCopy()
'
' MoveCopy Macro


'This macro will save the individual sheets into their respective workbooks
and save them to the Obso Need Files
Dim stDate As Date
stDate = Now()



'Co 755 and 764 Southwestern
Sheets(Array("Co 755 Exploded", "Co 764 Exploded")).Select
Sheets("Co 755 Exploded").Activate
Sheets(Array("Co 755 Exploded", "Co 764 Exploded")).Copy
ActiveWorkbook.SaveAs Filename:= _
"T:\Period End Schedules\Inventory Account Schedules\Inventory
Obsolescence\Obso Need Files\2006-02 Obsolescence Files - Heaverneck.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Windows("2006-02 Obsolescence Files.xls").Activate
--
Hlewis


"Ron de Bruin" wrote:

Hi Hlewis

You can use this in the file name for thw month

MsgBox Format(Month(Now) - 1, "mm")


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Hlewis" wrote in message ...
I have an Excel spreadsheet that contains several tabs which will each be
saved off to the same folder but with different names. The file names will
follow the same naming convention (i.e. YYYY-MM Name of compay - location).

I would like to have the code create the file name for me. This files will
always be created the 2nd day after the month end. I need the date portion
of the file name to be the 4-digit year and the previous 2 digit month. I
would like a message box to be displayed prior to saving each file that will
display the proposed file name. If the name is not correct, I would like the
message box to allow you to change the file name before saving. Is there any
to do this?

--
Hlewis






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save As Function Hlewis Excel Programming 1 February 3rd 06 08:03 PM
Always prompted for Save with function GM Excel Programming 3 February 3rd 06 07:56 PM
Save and Save as Function gone Michael S. Excel Programming 2 June 27th 05 06:41 PM
Disabling Save Function TheRobsterUK Excel Discussion (Misc queries) 2 May 31st 05 05:02 PM
need to save values from a function before it changes Ron Excel Worksheet Functions 1 October 29th 04 06:29 AM


All times are GMT +1. The time now is 06:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"