PC Review


Reply
Thread Tools Rate Thread

Changing Filename in VBA

 
 
=?Utf-8?B?U3VwZXJMQw==?=
Guest
Posts: n/a
 
      3rd Jan 2007
Workbooks.Open Filename:="R:\Daily Revenue Report\Daily
Revenue\THKL-DRR.xls"
Sheets("report").Select
ActiveSheet.Unprotect
Windows("drr0107.XLS").Activate

From the code above, every month a new "drrmmyy.xls" file will be created
(where mm = month & yy = year). What codes do I need to write so that the
macro will automatically use the new filename to replace the previous month,
i.e. in feb-07 the new file will be drr0207 and this will replace the drr0107
file in the code above?

Greatly appreciate any and all forms of assistance rendered! Thanx very much
:-)
 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      3rd Jan 2007
Assuming the file is made within the month it represents:

Dim sFileName as String
sFileName = "drr" & Format(Now, "mmyy") & ".XLS"

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______



"SuperLC" <(E-Mail Removed)> wrote in message
news:C6A68578-0F43-4352-A0E8-(E-Mail Removed)...
> Workbooks.Open Filename:="R:\Daily Revenue Report\Daily
> Revenue\THKL-DRR.xls"
> Sheets("report").Select
> ActiveSheet.Unprotect
> Windows("drr0107.XLS").Activate
>
> From the code above, every month a new "drrmmyy.xls" file will be created
> (where mm = month & yy = year). What codes do I need to write so that the
> macro will automatically use the new filename to replace the previous
> month,
> i.e. in feb-07 the new file will be drr0207 and this will replace the
> drr0107
> file in the code above?
>
> Greatly appreciate any and all forms of assistance rendered! Thanx very
> much
> :-)



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing the filename in a Link Ben Microsoft Excel Misc 1 12th Aug 2009 04:20 PM
PivotTables and Changing the FileName ONeill.Elizabeth@gmail.com Microsoft Excel Programming 0 12th Oct 2006 10:04 PM
Changing filename =?Utf-8?B?ZnVsbGVycw==?= Microsoft Excel Programming 5 23rd Feb 2006 04:01 PM
FileName and Path Not Changing =?Utf-8?B?RG9u?= Microsoft Word Document Management 2 10th Feb 2006 03:36 AM
changing a filename in C# J. Marshall Latham Microsoft C# .NET 8 15th Mar 2004 01:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:28 PM.