Hi,
I cant get my formula to create a unique ID when my User Form is submitted to my excel table. All i need is a simple ID (1,2,3,ect). When I click on my submit button on my user form, I want it to create a Unique ID on my table. The current code I am using for my user form is as follows: the ID will start in B3
Formula:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("32 Event Database")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check Date
If Trim(Me.Cbo45.Value) = "" Then
Me.Cbo45.SetFocus
MsgBox "Please enter a 45"
Exit Sub
End If
'copy the data to the database
'use protect and unprotect lines,
With ws
ws.Unprotect "AVO29"
.Cells(iRow, 1).Value = Me.txt45.Value
.Cells(iRow, 2).Value = Me.Cbo5.Value
.Cells(iRow, 3).Value = Me.CboC.Value
.Cells(iRow, 4).Value = Me.CboAmPm.Value
.Cells(iRow, 5).Value = Me.CboEvent.Value
.Cells(iRow, 6).Value = Me.txtHrs.Value
.Cells(iRow, 7).Value = Me.txtComm.Value
.Cells(iRow, 8).Value = Me.Cborm.Value
.Cells(iRow, 13).Value = Me.CboFa.Value
.Cells(iRow, 9).Value = Me.CboGae.Value
.Cells(iRow, 10).Value = Me.CboAie.Value
.Cells(iRow, 14).Value = Me.CboAV1.Value
.Cells(iRow, 15).Value = Me.CboAb2.Value
.Cells(iRow, 16).Value = Me.CboAl3.Value
.Cells(iRow, 17).Value = Me.CboAt4.Value
.Cells(iRow, 12).Value = Me.CboPx.Value
.Cells(iRow, 11).Value = Me.TxtSd.Value
ws.Protect "AVO29"
End With
'clear the data
Me.Cbox.Value = ""
Me.Cboxxx.Value = ""
Me.Cbobb.Value = ""
Me.Cboscxt.Value = ""
Me.txtkkk.Value = ""
Me.txtlll.Value = ""
Me.Cbommm.Value = ""
Me.Cbocvd.Value = ""
Me.Cbosde.Value = ""
Me.Cbowes1.Value = ""
Me.CboAbn2.Value = ""
Me.CboAV3.Value = ""
Me.CboAO4.Value = ""
Me.CboPad.Value = ""
Me.TxtSmp.Value = ""
Me.CboFoa.Value = ""
Me.txtDate.SetFocus
'inform user
MsgBox "New Record Saved To 123 Database", 64, "New Reccord"
Bookmarks