VBA ID generator with letters and numbers.

Mysterr42

New Member
Joined
Jan 20, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I´m trying to add a id generator for a form that creates a unique ID in sequence (letters and numbers) and automatically adds to the first cell in the excel sheet.
So far no sucess, any solutions?
Thank you.

This is what i got:
VBA Code:
Private Sub CommandButton3_Click()

Dim emptyRow As Long
Dim LR As Integer

'Make Sheet1 active
Sheet15.Activate

'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1

'ID generator
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & LR + 1) = "A" + CStr(Right(Cells(LR, 1).Text, Len(Cells(LR, 1).Text) - 1) + 1)

'Transfer information
Cells(emptyRow, 1).Value = A
Cells(emptyRow, 2).Value = TextBox1.Value
Cells(emptyRow, 3).Value = ComboBox1.Value
Cells(emptyRow, 4).Value = ComboBox2.Value
Cells(emptyRow, 5).Value = TextBox12.Value
Cells(emptyRow, 6).Value = ComboBox4.Value
Cells(emptyRow, 7).Value = ComboBox10.Value
Cells(emptyRow, 8).Value = TextBox11.Value
Cells(emptyRow, 9).Value = ComboBox6.Value
Cells(emptyRow, 10).Value = ComboBox7.Value
Cells(emptyRow, 11).Value = ComboBox8.Value
Cells(emptyRow, 12).Value = ComboBox9.Value
Cells(emptyRow, 13).Value = TextBox4.Value
Cells(emptyRow, 14).Value = TextBox5.Value
Cells(emptyRow, 15).Value = TextBox6.Value
Cells(emptyRow, 16).Value = TextBox2.Value
Cells(emptyRow, 17).Value = TextBox3.Value
Cells(emptyRow, 18).Value = TextBox7.Value
Cells(emptyRow, 19).Value = TextBox9.Value
Cells(emptyRow, 20).Value = TextBox10.Value

Unload Me

End Sub
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,833
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
Delete the lines in red
Rich (BB code):
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1

'ID generator
LR = Range("A" & Rows.Count).End(xlUp).row
Range("A" & LR + 1) = "A" + CStr(Right(Cells(LR, 1).Text, Len(Cells(LR, 1).Text) - 1) + 1)

'Transfer information
Cells(emptyRow, 1).Value = A
Cells(emptyRow, 2).Value = TextBox1.Value
Cells(emptyRow, 3).Value = ComboBox1.Value
And change "emptyRow" to LR+1
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,833
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,122,352
Messages
5,595,657
Members
414,006
Latest member
Davefromlondon

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
Top