Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Gai Gai is offline
external usenet poster
 
Posts: 16
Default a macro that will change the file names within it after running

I have made a rode for my own back. I have developed a very large excel
file(s) which, depending on the file, will have up to 178 worksheets within
it. The sheets are protected individually because the people entering data
into the sheets have little idea of excel and there is a lot of formula and
hyperlinks.

Each six weeks I have to archive the file to another location, give it a new
name, put a new blank template in the original location, unprotect the second
file, update the links it refers to to the new name of the file I just
created (this is because parts of the file refers to the last period data).
Some of the relating code is below:

ActiveWorkbook.SaveAs Filename:= _
"P:\unit\fmc\archive\6 wkly 21102006.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

Sheets("Files").Select Replace:=False
Cells.Select
Range("F1:L80").Activate
Selection.Replace What:="dummyFile", Replacement:="21102006", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

What I have to do presently is remember to go to each file at some point
during their six week cycle to change the macro manually to the next date. ie
do a "replace" in visual basic for 21102006 and replace to 02122006, and the
next month find 02122006 and replace with 13012007, and so on. I have
problems relying on my memory!!

What I want is to be able to run something at the end of the macro, or in a
separate but relating macro to do this for me after the archiving macro has
run. I have searched the bowels of the discussion group and have yet not
found anything, but bare in mind- I am still learning!

Cheers
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default a macro that will change the file names within it after running

Dim PathFilename as string
PathFilename="P:\unit\fmc\archive\6 wkly " & Format(now(),"ddmmyyyy") &
".xls"

ActiveWorkbook.SaveAs Filename:= PathFilename, FileFormat:=xlNormal, _

If the date in the file name is not based on now (that day), then:
- Separate the date from the current filename
- Add the correct number of days/weeks using DateAdd
- Use that date in place of Now() in the above.

NickHK

"Gai" wrote in message
...
I have made a rode for my own back. I have developed a very large excel
file(s) which, depending on the file, will have up to 178 worksheets

within
it. The sheets are protected individually because the people entering data
into the sheets have little idea of excel and there is a lot of formula

and
hyperlinks.

Each six weeks I have to archive the file to another location, give it a

new
name, put a new blank template in the original location, unprotect the

second
file, update the links it refers to to the new name of the file I just
created (this is because parts of the file refers to the last period

data).
Some of the relating code is below:

ActiveWorkbook.SaveAs Filename:= _
"P:\unit\fmc\archive\6 wkly 21102006.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

Sheets("Files").Select Replace:=False
Cells.Select
Range("F1:L80").Activate
Selection.Replace What:="dummyFile", Replacement:="21102006", LookAt:=

_
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

What I have to do presently is remember to go to each file at some point
during their six week cycle to change the macro manually to the next date.

ie
do a "replace" in visual basic for 21102006 and replace to 02122006, and

the
next month find 02122006 and replace with 13012007, and so on. I have
problems relying on my memory!!

What I want is to be able to run something at the end of the macro, or in

a
separate but relating macro to do this for me after the archiving macro

has
run. I have searched the bowels of the discussion group and have yet not
found anything, but bare in mind- I am still learning!

Cheers



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
Running a macro on cell value change Brettjg Excel Discussion (Misc queries) 2 March 28th 07 02:55 PM
Running a macro on cell value change Mike Excel Discussion (Misc queries) 0 March 28th 07 01:13 AM
Running a macro on cell value change Brettjg Excel Discussion (Misc queries) 0 March 28th 07 12:08 AM
Change file names in a folder TISR Excel Programming 2 April 12th 06 01:35 PM
How to change a macro while running others? MJO Excel Programming 4 April 22nd 05 06:51 PM


All times are GMT +1. The time now is 06:54 AM.

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"