VanillaSky
New Member
- Joined
- Sep 9, 2017
- Messages
- 8
Hi.
I want my userform to insert unique id for every new entry starting from 1. Could you please take a look at the code below and advise how to edit it to add this feature?
I want my userform to insert unique id for every new entry starting from 1. Could you please take a look at the code below and advise how to edit it to add this feature?
Code:
Private Sub OutPutData()
Dim NextRow As Range
Set NextRow = Worksheets("List").Cells(Rows.Count, "B").End(xlUp).Offset(1).Resize(1, 6)
With Me
NextRow.Cells(1) = .TextBox_PI_Case
NextRow.Cells(2) = .TextBox_Company_Name
NextRow.Cells(3) = "NEW"
NextRow.Cells(4) = .TextBox_RoR
NextRow.Cells(5) = .TextBox_Comments
NextRow.Cells(6) = Date
End With
End Sub
Private Sub ClearData()
With Me
.TextBox_PI_Case = ""
.TextBox_Company_Name = ""
.TextBox_RoR = ""
.TextBox_Comments = ""
.TextBox_PI_Case.SetFocus
End With
End Sub
Sub CommandButton_Submit_Click()
'check for a Name number
If Trim(Me.TextBox_Company_Name.Value) = "" Then
Me.TextBox_Company_Name.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If
'copy the data to the database
OutPutData
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
ClearData
End Sub
Private Sub CommandButton_Cancel_Click()
Unload Me
End Sub