attach please your file
attach please your file
Hi
You may also try this one.
Code:Sub kTest()
Dim strFName As String
Dim strExtn As String
Dim strPath As String
Dim lngFNum As Long
Dim nmFNum As Name
Const FName = "ivan ivanov"
On Error Resume Next
Set nmFNum = ThisWorkbook.Names("FNum")
On Error GoTo 0
If nmFNum Is Nothing Then
Set nmFNum = ThisWorkbook.Names.Add("FNum", 1, 0)
lngFNum = 1
Else
lngFNum = Evaluate("FNum") + 1
nmFNum.RefersTo = lngFNum
End If
strFName = ThisWorkbook.FullName
strExtn = Mid$(strFName, InStrRev(strFName, "."))
strPath = Left$(strFName, InStrRev(strFName, "\"))
ThisWorkbook.SaveCopyAs strPath & FName & lngFNum & strExtn
End Sub
Yes, yes, this is exactly what I wanted. That's what's
Infinitely many thanks. You are just amazing, so much that I can not even describe it and to express it in words.
Thank you very much. :notworthy::notworthy::notworthy:
Admin - thus giving my reputation, because when you press the asterisk does not allow me to give you the necessary points.
Attachment 990
Admin
very interesting code, can you comment it ?
Hi
here you go.
Code:Sub kTest()
Dim strFName As String
Dim strExtn As String
Dim strPath As String
Dim lngFNum As Long
Dim nmFNum As Name
Const FName = "ivan ivanov"
On Error Resume Next
Set nmFNum = ThisWorkbook.Names("FNum") 'a defined name
On Error GoTo 0
If nmFNum Is Nothing Then 'for the first time we have to add the name
Set nmFNum = ThisWorkbook.Names.Add("FNum", 1, 0) 'add the defined name for the first time (0 - visible=false)
lngFNum = 1
Else
lngFNum = Evaluate("FNum") + 1 'get the previous number + 1
nmFNum.RefersTo = lngFNum 'assign the new number
End If
strFName = ThisWorkbook.FullName
strExtn = Mid$(strFName, InStrRev(strFName, "."))
strPath = Left$(strFName, InStrRev(strFName, "\"))
ThisWorkbook.SaveCopyAs strPath & FName & lngFNum & strExtn
End Sub
Than you, I understand now, I think it would be better a visible name, very good idea.