Userform autofill fillout ID number

RyannguyenS2k

New Member
Joined
Jun 27, 2018
Messages
7
I have created a simple UserForm to enter new equipment details to the Tooling list in the spreadsheet, form works fine except for one little thing, which is New Tool ID. Basically what I need this for to do is once form is opened/called new Tool ID need to be created, which could be and Alfa numerical set of characters like AA-01234, AA-01235, AA-01236 and so on.
Also, is there a way of posting newly added Tool ID in the MsgBox along with MsgBox "One record added to Customers List. New Customer ID is "
All of my attempts to create this are failing and causing errors, which I really cannot figure out since I am new to VBA and had never used it until now.
Here is my code, Customer ID is TextBox1.
Thanks in advance [![enter image description here][1]][1] Here is the code working for me but it won't subtract the words out.


<code>
Code:
Private Sub CommandButton1_Click()
If Application.WorksheetFunction.CountIf(Range("A:A"), Me.TextBox1) > 0 Then
If MsgBox("Tool Name Already Exists.Do you want to continue?", vbQuestion + vbYesNo) <> vbYes Then
Exit Sub
End If
End If

If TextBox1.Value = "" Or TextBox2.Value = "" Or TextBox4.Value = "" Or TextBox5.Value = "" Or TextBox6.Value = "" Then
If MsgBox("Form is not complete. Do you want to continue?", vbQuestion + vbYesNo) <> vbYes Then
Exit Sub
End If
End If
Dim ssheet As Worksheet

Set ssheet = ThisWorkbook.Sheets("2018")
nr = ssheet.Cells(Rows.Count, 1).End(xlUp).Row + 1

ssheet.Cells(nr, 1) = TextBox1.Value
ssheet.Cells(nr, 2) = TextBox2.Value
ssheet.Cells(nr, 3) = TextBox3.Value
ssheet.Cells(nr, 4) = TextBox4.Value
ssheet.Cells(nr, 5) = TextBox5.Value
ssheet.Cells(nr, 6) = TextBox6.Value
ssheet.Cells(nr, 7) = TextBox7.Value

Call resetForm

End Sub

Sub resetForm()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
Data_Entry.TextBox1.SetFocus

End Sub
Private Sub CommandButton2_Click()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
Data_Entry.TextBox1.SetFocus
End Sub

Private Sub UserForm_Initialize()

Me.TextBox1 = Application.WorksheetFunction.Max(Range("A:A")) + 1

Me.TextBox3 = Date

End Sub
    Private Sub UserForm_Initialize()
    Me.TextBox1 = Application.WorksheetFunction.Max(Range("A:A")) + 1
    Me.TextBox3 = Date
    End Sub
yQABC.jpg
</code>
 
Last edited by a moderator:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Cross posted https://stackoverflow.com/questions...llout-id-number-ans-subtract-the-word-infront

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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