automatically updating userid us

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

Automatically updating the userid in a userform | Excel forum

resolvedResolved · Medium Priority · Version 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.

 

Training courses

 

Training information:

See also:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Paste a web address into the hyperlink address field

If you copy a web address the only way to paste into the address field of the hyperlink box is to use CTRL + V. Right click paste does not work.

View all Excel hints and tips


Server loaded in 0.08 secs.