Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Tim
 
Posts: n/a
Default 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 a
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.

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

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 a
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
  #3   Report Post  
Tim
 
Posts: n/a
Default


I figured it out.
Thak you for you answer Dave
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



All times are GMT +1. The time now is 04:37 AM.

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

About Us

"It's about Microsoft Excel"