Auto Generate Sequential Serial Number when Initializing the Userform

himaruasuka

New Member
Joined
May 26, 2022
Messages
12
Office Version
  1. 2013
Platform
  1. Windows
  2. Mobile
Good day! I already searched the threads and look for an answer to my question but I can't find the answer. Though I am new to excel vba, i don't know how to explain.

I want to generate a Serial number or an Order Number Code when clicking the command button (Add Order) and display the Number Code in the assigned textbox.
I want to display the code like this "HP-0000" "HP-0001" so on so forth.. But when I click the button, it only display one-digit number only.

I just happen to find this code and try, but its not what I am looking ..

VBA Code:
Private Sub UserForm_Initialize()
pos_orderno.Value = Sheet4.Range("F5").CurrentRegion.Rows.Count
End Sub

also the another problem was It begins to number "4", I tried to delete the other table row but it display to number "3". I do not know what happen.

Capture1.PNG
Capture2.PNG


Can anyone help me to fix this? Thank you in advance~
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
try:
Code:
pos_orderno.Value = "HP-" & FORMAT(Sheet4.cells(rows.count,"F").end(xlup).row-3,"0000")
 
Upvote 0
Solution

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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
Back
Top