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
Cheers !
Excel Range to BBCode Table
Use Social Networking Tools If You Like the Answers !
Message to Cross Posters
@ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)
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.
Admin - thus giving my reputation, because when you press the asterisk does not allow me to give you the necessary points.
Screen_03 Jul. 16 20.50.jpg
Last edited by k0st4din; 07-16-2013 at 10:53 PM.
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
Cheers !
Excel Range to BBCode Table
Use Social Networking Tools If You Like the Answers !
Message to Cross Posters
@ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)
Than you, I understand now, I think it would be better a visible name, very good idea.
Bookmarks