Userform Unique reference number question

  • Hi,


    I current use the below piece of code to generate a sequential reference number on a userform.


    Code
    With ReferenceNumber
           .Value = Cells(1, 1) & Format(Cells(Rows.Count, 1).End(xlUp).Row, "000")
          .Enabled = False
        End With


    This works fine but what im trying to do is not have it done by counting the row as I already have some reference numbers in there.


    The sheet that it transfers to starts at row 3 but the count starts on "002".


    Is it possible to have it count directly on from the last reference without it being linked to the row its on?


    Thanks in advance.

  • Re: Userform Unique reference number question


    Hi GhostMonkey72,


    Try:

    Code
    With ReferenceNumber
        .Value = Cells(1, 1).Value & Format(Val(Replace(Cells(Rows.Count, 1).End(xlUp).Value, Cells(1, 1).Value, "")) + 1, "000")
        .Enabled = False
    End With

    [COLOR="Purple"]Regards,[/COLOR]
    [COLOR="Purple"]Batman.[/COLOR]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!