macro to change the names and delete closed books

Hi,

In a folder located in C:\Documents and Settings\Tim\My 
Documents I have a number of workbooks and I need to 
create a code which will change the names of the 
workbooks automatically.
To be more specific the names of the workbooks are: 
1,2,3,4 and 5, and the code should change the names like 
this: book "5" becomes 4, 4 becomes 3, 3 becomes 2, and 
the name of book "2" becomes 1, book 1-delete. 
Any help is highly appreciated.

0
anonymous (74722)
2/5/2005 2:18:51 AM
excel.misc 78881 articles. 5 followers. Follow

2 Replies
158 Views

Similar Articles

[PageSpeed] 19

how about:

Option Explicit
Sub testme()
    Dim myFolder As String
    Dim iCtr As Long
    
    myFolder = "C:\Documents and Settings\Tim\My Documents"

    If Right(myFolder, 1) <> "\" Then
        myFolder = myFolder & "\"
    End If    
    
    On Error Resume Next 'in case the name isn't there
    Kill myFolder & "delete.xls"
    Name myFolder & "1.xls" As myFolder & "delete.xls"

    For iCtr = 2 To 4
        Name myFolder & iCtr & ".xls" As myFolder & iCtr - 1 & ".xls"
    Next iCtr
    On Error GoTo 0
    
End Sub

Tim wrote:
> 
> Hi,
> 
> In a folder located in C:\Documents and Settings\Tim\My
> Documents I have a number of workbooks and I need to
> create a code which will change the names of the
> workbooks automatically.
> To be more specific the names of the workbooks are:
> 1,2,3,4 and 5, and the code should change the names like
> this: book "5" becomes 4, 4 becomes 3, 3 becomes 2, and
> the name of book "2" becomes 1, book 1-delete.
> Any help is highly appreciated.

-- 

Dave Peterson
0
ec357201 (5290)
2/5/2005 9:40:05 PM
I figured it out.
Thak you for you answer Dave
0
anonymous (74722)
2/6/2005 9:39:01 PM
Reply:

Similar Artilces:

How do I get address book to include e-mail address?
When I select to: box in the new message the search box does not include the e-mail address and is not included in the address line. How do i fix that? Any chance the Contacts folder has lost it's "Show this folder as an E-mail Address Book" checkmark in Properties? http://support.microsoft.com/kb/197577/en-us "Show this folder as an e-mail Address Book" check box is dimmed in Outlook Contact folder properties Hal -- Hal Hostetler, CPBE -- hhh@kvoa.com Senior Engineer/MIS -- MS MVP-Print/Imaging -- WA7BGX http://www.kvoa.com -- "When News breaks, we fix it!...

automatically close second workbook 12-16-09
i have put the following code in to workbook 'A' to close workbook 'B' but it does not close book 'B' there is no error message Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Workbooks("B.XLS").Close SaveChanges:=False ActiveWorkbook.Close SaveChanges:=True End Sub Several of us have tested your code..........both workbook_open which opens B.xls when A.xls opens and the workbook_beforeclose code. Works fine for me. All I can think of is that you are opening B.xls in a separate instance of Excel. If t...

Emptying 'Deleted Items' folder on exit
I am running WLM version 2009 (Build 14.0.8089.0726) on Windows 7 with all the latest updates. I have 'Empty messages from the Deleted Items folder on exit' checked under Maintenance, but they're all still there when I exit and restart WLM. Is there another setting I should be looking at to make this work? TIA, -- SC Tom Tom, I experienced the same thing earlier today. I'm new to WLM and found that if you "checked" the ''Empty messages from the Deleted Items folder on > exit' after there were items in the Deleted Items folder, it ...

referencing to worksheet names in macro for each new worksheet inserted
Hi I created a code to insert new worksheets and rename them according t values on the new worksheet itself. Say in Cell D1, i have th worksheet name. My question is when i want to refer to this worksheet in subsequen coding, how should i code it? For eg, How should i write the ???? for Sheets("????").select? Would creatin the a variable to store the names help? Thanks in advance Ken -- Message posted from http://www.ExcelForum.com After inserting your new worksheet set it's name equal to a variable. For example SHEETS.ADD VWORKSHEET = ACTIVESHEET.NAME This method ...

VB code for Macro
I have set up a rule on my InBox to check for specific words and move emails to my Work folder. Now I review emials in my Work folder and drag and drop them into 1 of 4 folders based on a number 1-4. After clicking on the folder, I need to perform the following on each of the four folders: Click on first email in the folder Clt+A (to select all the emails in the folder) Ctl+C (to copy) Drag the selections to a folder name HH Click #_Button (customized button set to send an email) Ctl+v (to paste the contents in the body of the email) Click Send Steps without the comments: Click folde...

Most recommended Exchange book?
I was wondering if you guys could recommend me a good "must have" Exchange 2003 reference book to keep around the office. Something more geared for an all encompasing and easy to use reference guide than certification testing would be appropriate. Thanks! On Mar 13, 8:46 am, Chris Lukowski <ChrisLukow...@discussions.microsoft.com> wrote: > I was wondering if you guys could recommend me a good "must have" Exchange > 2003 reference book to keep around the office. Something more geared for an > all encompasing and easy to use reference guide than certificati...

How to Change Value of Active Control
I'm writing a routine to change the value of any Active Control to null. I can get the name of the control using ActiveControl.Name but I can't figure out the syntax to change the value of this control. I've tried assigning it to variables but variables aren't working in a: Forms![variable]![variable] = "" Help "Sondreli" <Sondreli@discussions.microsoft.com> wrote in message news:AA05A840-2AFE-4F98-ABE9-5D2DD17AE0B8@microsoft.com... > I'm writing a routine to change the value of any Active Control to null. > I > can g...

Can I see the summary report of each resouce's booking status ?
Here we using AutoAcceptAgent to booking resource account like meeting room. Is there any method to view the summary report ? for example, a summary report show which meeting room booked by which one for what agenda. I have tried to use public folder with email address, but can't register by AutoAcceptAgent. Any one has any idea of such request ? Pls help soon. Thanks. On Thu, 20 Jul 2006 19:14:02 -0700, Enid <Enid@discussions.microsoft.com> wrote: >Here we using AutoAcceptAgent to booking resource account like meeting room. >Is there any method to view the summary repor...

Pivot Tables & changing data
Hi - I have never used pivot tables in Excel before so hopefully what I am going to ask is possible and not too complicated for me.... :o) I am working with Excel 2003. I have a pivot table already set up and the information is pulling data from a row titled "sum of Subscriber". I added new data in a new column from the main spreadsheet and I would like to pull the data from there. Its titled "Adj Subscriber". Is it possible to switch it? If so, how? Thanks, Anna Marie Anna wrote: > Hi - I have never used pivot tables in Excel before so hopefully what I am &...

Module name in
Hi, when your are in the EXCEL code editor, you have on your left the name of the modules. I find anoying the fact of having to remember the module name or edit one by one each modules to find for intense a piece of code as a reference. Is there a better way to do it in that environment like renaming the module with specific name? Thank's ahead!. You can rename the module. Most of the people here probably group their macros into similar function macros in different modules, and name the module accordingly. This makes it much simpler to find. You can also do a find, Ctrl-F, and set the ...

Names, Addresses In A Table...
I Am Putting Names And Addresses In A Table For A Directory I Am trying To Put Together, 6 Rows And 3 Columns. 18 Companies To A Page, I Will Have Approx. 300 Pages When Complete. My Question Is: Is There Any Way To Make Them Go In Alphabetical order By Name Of Company? I Am Very Greatful To Anyone Who May Be Able To Give Me Some Help. Thank You very Very Much. PS: I Am New To This Kind Of Software And Would Like To Say To MS PUBLISHER...You Are Very RUDE!! This is a multi-part message in MIME format. ------=_NextPart_000_01E6_01C43075.4641A2B0 Content-Type: text/plain; charset="Utf...

How do I get deleted items that stay in inbox with line thru them.
I inherited a computer at work. Outlook is setup so that when I delete a message it stays in the inbox, with a line thru it. How do I get the deleted items to go automatically to the deleted item folder? "rwwhit" <rwwhit@discussions.microsoft.com> wrote in message news:7D17761E-CD1B-4D04-BACB-B0D837C4DD93@microsoft.com... >I inherited a computer at work. Outlook is setup so that when I delete a > message it stays in the inbox, with a line thru it. How do I get the deleted > items to go automatically to the deleted item folder? That's normal behavior...

Preventing Recipient Names from Showing
I have a long list of people I am addressing a message to. I want the recipient to see that it is coming to them, but not be able to see anyone else's name/address that it's being sent to. I've tried the BCC field but then even the recipient does not see that it was sent to them. I'm afraid they will think it is junk mail if they don't see it addresses to themselves. Check out http://www.slipstick.com/addins/mail.htm#massmail for other options -- PATRICK REED [Outlook - MVP]~~~~~~ -Microsoft Certified Professional (MCP) -Have you checked http://www.slipstick...

email addressbook name order (last, first)
I'm using stand alone Outlook 2007. When I create a new email then hit "To" and my address book come up all the names are arranged first, last. How do I order them last, first? Thank you Change the sort here: Tools menu > Account Settings > Address Book tab > Highlight Outlook Address Book > Click Change "Dave R" <rezin8@threshold-studio.com> wrote in message news:D14B3FCF-D6F2-453D-8BEC-B398C687ED1F@microsoft.com... > I'm using stand alone Outlook 2007. When I create a new email then hit > "To" and my address book come up...

Money 2005 Closes Abruptly
I am using Money 2005 Premium and all of a sudden everytime I perform an update now, the program closes immediately for no known reason. Any changes I made are still there when I open the program again, but I cannot execute an update now on various accounts. Any ideas or help? Thanks I figured a work around. Selecting one or two updates at a time works, but doing all accounts and investment stuff at the same time causes the program to immediately shut down. "Dig" wrote: > I am using Money 2005 Premium and all of a sudden everytime I perform an > update now, the pro...

How to change default printing parameters on Excel & ......
How to change the default printing parameters on Excel & keep them changed for future workbooks. Example: Normally I use Printing margins 0.25 on all directions, but default printing margins are 0.75. I want to change them to set 0.25 as DEFAULT. If you start a new workbook and change the page layout (for all the sheets), you can save it into your XLStart folder as Book.xlt. Excel will use that as the basis for new workbooks. You can change a lot of settings that way--including orientation, headers/footers.... Amjad wrote: > > How to change the default printing parameters ...

Post Closed Batches to Quickbooks
Hi, We have just recently installed RMS and have completed the Assign GL Accounts. We want to test batch posting, so we created a copy of our QB file to play with (in case it blows up!) We are running the Canadian edition of Quickbooks Premier 2005: Retail and Repair Edition. So, what do we do now? I've gone to Journal/Post Closed Batch, clicked the batches, but don't know what to do with 'File Name:' What about after that? And once everything is working great, how do we re-post the batches to our 'real' copy of QB? Thanks for any help anyone can provide! Save...

Excel 'hangs' when deleting a row
when i delete a row in excel 2000, everything locks up! and when lookup at Task Manager/Processes, it's MEM USAGE goes up to 22K o more! i tried doing it in another file but i experienced no error. the dat is in LAN. all data are filtered when the deletion began. however i ca delete files before. please help, anyone.... -- Message posted from http://www.ExcelForum.com The best thing is to free up memory (assuming your file is large). Clos all applications you do not require at the time and any workbooks no in use. Dunca -- Message posted from http://www.ExcelForum.com ...

How to delete duplicate data
Hi, I am using excel to consolidate monthly room booking data. I have a date column and time column. May I know how to to delete those rows which contains duplicate data with same date stated in the date columnand and same time range in the time column? Thank you. Data>filter>advanced filter, unique records only and copy to another location -- Regards, Peo Sjoblom Excel 95 - Excel 2007 Northwest Excel Solutions www.nwexcelsolutions.com (Remove ^^ from email) "PL" <PL@discussions.microsoft.com> wrote in message news:F45DAE2B-252D-4E17-81D8-0F4C060BCB21@m...

Can you delete and empty an open email
Hi there Can you delete and empty an open email? I know I can delete and empty a closed email by holding down shift and then deleting, but have not been able to figure out how to delete and empty from an open email. Is this even possible? Thanks for your help. Kylie On Wed, 18 May 2005 20:01:03 -1000, Kylie B"" <KylieB@discussions.microsoft.com> wrote: > Hi there > > Can you delete and empty an open email? I know I can delete and empty a > closed email by holding down shift and then deleting, but have not been > able > to figure out how to delet...

Change color of multiple autoshapes
I need to change the color of several autoshape based on different cells I know how to change one autoshape using a worksheet_change event but i can't just copy and paste this and change the object name + cell name. is it possible to have multiple worksheet_change events in the same worksheet?? T-bone, You have only one worksheet_change event, but in it you can test to see which cell was changed with something like If not Intersect(Target, Range("A1") is nothing then ' do range A1 stuff here end if If not Intersect(Target, Range("A2") is nothing then &#...

Using a VBscript to copy/delete/move Outlook messages
I need to write a VBscript to: - open my Outlook (2000 or XP) mailbox - read the list of the folders in either the Exchange Mailbox and in local ..pst files - open each folder and subfolders - read information about messages (i.e. sender, recipient, creation date, and so on) - move, copy or delete messages based on the above information Can anybody please provide a pointer to a sample I can start from? Regards Marius ...

IE8 was deleted from my windows 7 and I cannot find correct downlo
I have a two month old Toshiba and deleted IE8 because of crashes. Trying to find the correct download to reinstall. The IE8 homepage just says it is included in windows 7 but does not show the download file....... ARRRG. Tried Vista IE8 download file but message says it not the correct operating system. On Sun, 21 Mar 2010 20:50:01 -0700, pawntonian <pawntonian@discussions.microsoft.com> wrote: >I have a two month old Toshiba and deleted IE8 because of crashes. Trying to >find the correct download to reinstall. The IE8 homepage just says it is >included in wind...

Recovery after "do not save changes" selected accidently
I mistakenly clicked on "do not save changes" for a worksheet (file) that i'd been working on (I thought a different file was highlighted). As it turns out I had not saved the original file in over a day, though the autosave is set up. is there any way to get my file back, or at least an intermediate version, instead of one with a day's less of work??? help!!!!!! Thanks very much for your help! Sorry to say, but your day's work is gone. -- Greeting from the Gulf Coast! http://myweb.cableone.net/twodays "Mayukh" <msukhatme@hotmail.com> wrote in...

Contacts vs Personal Address Book. Can't pull emails into TO fiel
Howdy, I'm using Outlook 2k3 and having a slight problem. WHen I view my Contact list in the main view, I have two sets (not sure why but I'll be combining them). These lists have standard name, email, etc. Problem is when I go to create a new email message and click the TO: button, it tries to look for my Personal Address Book which I don't have. How can I make it not use the PAB and use the Contacts list instead? Thanks. OK, I think I just stumbled on the issue. For some reason on my COntacts Properties, the check box to tell Outlook to use that in the Address Book ...