Auto Renumber not continuing with new number

tnemom

Board Regular
Joined
May 14, 2007
Messages
67
I have the following code that will autonumber based upon the estimators name, the year and the next sequential number on a sheet named "VariNum". The problem I am having is that this main workbook is a template and is renamed each time an estimate is created. When this happens the sequential number is reset to the original number before the sheet was renamed.

For example...I go into the estimate template and number the estimate 1013 then rename and save.

When I go back into the template to create a new estimate and number the estimate it wants to number as 1013.

How do I fix this?

Code:
Sub CreateEstimate()
Set wsEST = Sheets("Estimate")

ITName = Sheets("Input Form").Range("G34").Value & "-" & Sheets("Input Form").Range("J1").Value & "-" & Sheets("VariNum").Range("A1").Value

Msg = "Do you want to input this Number" & vbCrLf _
    & "" & ITName & vbCrLf _
    & " into your Estimate Sheet?"
    Ans = MsgBox(Msg, vbYesNo + vbQuestion, "New Number?")
    If Ans = vbNo Then
        Exit Sub
    Else
        Sheets("VariNum").Range("A1").Value = Sheets("VariNum").Range("A1").Value + 1
        wsEST.unprotect
        Sheets("Estimate").Range("C2").Value = ITName
        Sheets("Estimate").Select
    End If
    
MsgBox "A New Number has been Input." & vbCrLf _
      & vbCrLf _
      & ITName & vbCrLf _
      & vbCrLf _
      & "is now on your Estimate page."
End Sub

Thanks
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Glove_Man

Well-known Member
Joined
Feb 20, 2005
Messages
578
Maybe use a Global Public Variable rather than a cell in the sheet VariNum?

I don't know too much about this but I think it would work better.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,101
Messages
5,768,100
Members
425,453
Latest member
bince

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top