Hello!
I created UserForm for tracking purchases, in the Userform there is a combo box for selecting the type of purchase, 'DEBIT or CREDIT.
After selecting the purchase type there is a label box next to it that auto generates 'D0001' and 'C0001' before submitting.
The purchase numbers are going into column B and I want the form to pretty much look back at the sheet and add the next sequence numbers without any Duplicating.
Example:
D0001
C0001
D0002
D0003
C0002
This is the code I have now.
Sub FindNextPurchNum()
Dim Lastrow As Long
Dim ws As Worksheet
Set ws = Worksheets("Manager")
myName = UCase(Left(Me.CmbobxPay, 1))
myNum = Format(myNum + 1, "0000")
Lastrow = Application.WorksheetFunction.Max(Sheet3.UsedRange.Columns(2))
Me.Lbl1 = myName & myNum
End Sub
I created UserForm for tracking purchases, in the Userform there is a combo box for selecting the type of purchase, 'DEBIT or CREDIT.
After selecting the purchase type there is a label box next to it that auto generates 'D0001' and 'C0001' before submitting.
The purchase numbers are going into column B and I want the form to pretty much look back at the sheet and add the next sequence numbers without any Duplicating.
Example:
D0001
C0001
D0002
D0003
C0002
This is the code I have now.
Sub FindNextPurchNum()
Dim Lastrow As Long
Dim ws As Worksheet
Set ws = Worksheets("Manager")
myName = UCase(Left(Me.CmbobxPay, 1))
myNum = Format(myNum + 1, "0000")
Lastrow = Application.WorksheetFunction.Max(Sheet3.UsedRange.Columns(2))
Me.Lbl1 = myName & myNum
End Sub