Userform VBA Create Unique ID from values of several controls

richard_a

New Member
Joined
Jan 22, 2013
Messages
23
Hi Guys

I have a userform which collects data on 30 people (a department of employees) on a daily basis. I then have a command button which transfers all of the collected data to a table for longitudinal records.

At the moment the userform transfers fields such as date, company, department, name etc.

What I would like to do is populate a textbox (which will be hidden on the userform) with a unique ID (Named UnID*) for each person (record) made up of the values in some of the existing controls. I would like this code to run as an After_Update event linked to the final combobox they will select prior to data transfer.

What I have so far is this code below. But it's not correct and I don't know where to go from here

Code:
For i = 1 To 30
   Controls("UnID" & i).Value = Int(CDbl(DateBox.Value())) & Right(CompName.Value, 4) & Dep.Value & Left(("NameBox" & i), 3) & Right(("NameBox" & i), 3)
   Next i

Any pointers would be great, and apologies for what I'm sure are rookie errors in the attempted code

Thanks in advance,

Richard
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Does this work?
Code:
For i = 1 To 30
   Me.Controls("UnID" & i).Value = Int(CDbl(DateBox.Value())) & Right(CompName.Value, 4) & Dep.Value & Left(Me.Controls("NameBox" & i).Value, 3) & Right(Me.Controls("NameBox" & i).Value, 3)
Next i
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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
Back
Top