Hi everybody!
I am new at VBA, and I have some problem. I would like to make a code for copy a template sheet called V000 and name as V001. If V001 exsist call it V002... etc.
I already have found some formula but it's not working stg is missing and I don't know what:
Thanks for ur help!
Sub NewVendor()
'Copy template V000 and rename it
Dim V0 As Worksheet
Sheets("V000").Select
ActiveSheet.Copy After:=Sheets(Sheets.Count - 2)
Set V0 = ActiveSheet
Const strPrefix = "V0"
Const strFormat = "00"
Dim wsh As Worksheet
Dim lngMax As Long
Dim lngNum As Long
For Each wsh In Worksheets
If wsh.Name Like strPrefix & "*" Then
lngNum = Val(Mid(wsh.Name, Len(strPrefix) + 1))
If lngNum > lngMax Then
lngMax = lngNum
End If
End If
Next wsh
Set wsh = Worksheets.Add(After:=Worksheets(Worksheets.Count))
wsh.Name = strPrefix & Format(lngMax + 1, strFormat)
End Sub
Bookmarks