I think that part is OK:
In the immediate window:
?format(9999,"-00")
-9999
--
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison
Free & Pro versions
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
I should have noticed that this will fail and go into an infinite loop if
you have 99 copies. Add in this to prevent that:
FindAName:
i = i + 1
If i 99 Then
MsgBox "You have waaaaay too many backup files...."
Exit Sub
End If
....
HTH,
Bernie
MS Excel MVP
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Bob,
Sub BackUpWithIncrementedName()
Dim i As Integer
Dim myFN As String
i = 0
FindAName:
i = i + 1
myFN = ThisWorkbook.Path & "\Archive\" & _
Replace(ThisWorkbook.Name, ".xls", Format(i, "-00") & ".xls")
If Dir(myFN) = "" Then
GoTo DoTheSave
Else
GoTo FindAName
End If
DoTheSave:
ThisWorkbook.SaveCopyAs myFN
MsgBox "I just saved a copy as " & myFN
End Sub
HTH,
Bernie
MS Excel MVP
"Bob Zimski" wrote in message
...
I would like to make a make a backup copy and dump it into one directory
deeper called 'Archive' before manipulating the file in the current
directory. If the filename already exists in the Archive directory, then
I
would want to add a '-01' or '-02' etc.. to the next revision level. I
know
about the FileCopy command, but have no idea how to determine if the
file
already exists inthe archive directory and therefore add the next
available
revision number.
Thanks