Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

automatically updating userid us

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Automatically updating the userid in a userform

Automatically updating the userid in a userform

ResolvedVersion 2016

Natalie has attended:
Excel Advanced course

Automatically updating the userid in a userform

I have developed a userform. I am trying to work out how to automatically assign and update a user ID.

RE: Automatically updating the userid in a userform

Hi Natalie,

Thank you for the forum question.

What do you mean by assign and update a user id.

You can create userforms using VBA in Excel. Is your userform a VBA userform? If not please let me know more details about what you have created.

If it is a VBA userform the code below will add the user name in a text box on the userform:

Private Sub UserForm_Initialize()
Me.TextBox1.Text = Application.UserName
End Sub


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Automatically updating the userid in a userform

Hi Jen,

My userform has been made in Visual Basic.

The userform populates a table with customer information about an incident. When this information goes into the table I have to manually enter a code. I would like the form to be able to assign the ID automatically e.g. 001 and the next time the field is completed it will automatically assign 002 to the next entry.

RE: Automatically updating the userid in a userform

Hi Natalie,

First if you want the user id to be 001, 002, 003 you will need much more coding. 001 is a text string and you cannot just add one to it.

I have done a code below I hope will guide you in the right direction, but I have used numbers 1,2,3.

You will need to tell Excel to get the last ID used. In my example I have the IDs in column A. The code picks up the last ID used and then add one to it and enter it in the table.

Private Sub UserForm_Initialize()
Dim lId As Long
Sheets(1).Range("A1").CurrentRegion.Columns(1).Select
lId = Selection.Rows(Selection.Rows.Count).Value
Selection.Rows(Selection.Rows.Count + 1).Value = lId + 1
End Sub





Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Fri 26 Jan 2018: Automatically marked as resolved.

Excel tip:

Finding cells that have data restrictions

Click anywhere on the worksheet.
On the Edit menu, click Go To.
Click Special.
Click Data validation.
Click All.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.