Hello there,
I am currently trying (failing) to figure out some code to automatically add an autonumber to every new record my user makes using my custom built userform. I would like this number to be a visible column in the table. The table that has all the master data in constantly changes....so it cant be reliant on looking at the number in the above cell/row. Is what im trying to acheive possible?
Pls see attached workbook for my userform and code.
Here is a preview of the code i currently use to add a record.
[code]
Private Sub btnAddRecord_Click()
'next empty cell in column A
Set c = Range("a65536").End(xlUp).Offset(1, 0)
Application.ScreenUpdating = False 'speed up, hide task
'write userform entries to database
c.Value = Me.txtSurname.Value
c.Offset(0, 1).Value = Me.txtForename.Value
c.Offset(0, 2).Value = Me.ddlAssignee.Value
c.Offset(0, 3).Value = Me.txtPersNum.Value
c.Offset(0, 4).Value = Me.txtStartDate.Value
c.Offset(0, 5).Value = Me.txtEndDate.Value
c.Offset(0, 6).Value = Me.ddlDivision.Value
c.Offset(0, 7).Value = Me.ddlLocation.Value
c.Offset(0, 8).Value = Me.txtLineManager.Value
c.Offset(0, 9).Value = Me.txtVCS.Value
c.Offset(0, 10).Value = Me.ddlHealth.Value
c.Offset(0, 11).Value = "C"
'clear the form
With Me
.txtSurname.Value = vbNullString
.txtForename.Value = vbNullString
.ddlAssignee.Value = vbNullString
.txtPersNum.Value = vbNullString
.txtStartDate.Value = vbNullString
.txtEndDate.Value = vbNullString
.ddlDivision.Value = vbNullString
.ddlLocation.Value = vbNullString
.txtLineManager.Value = vbNullString
.txtVCS.Value = vbNullString
.ddlHealth.Value = vbNullString
End With
Application.ScreenUpdating = True
End Sub
[code/]
Thanks
Bookmarks