Unique ID# with unknown letters

KDS14589

Board Regular
Joined
Jan 10, 2019
Messages
182
Office Version
  1. 2016
Platform
  1. Windows
I have a userform and I' using this code to fill A textbox (txt_record) with an ID # for that record. As of now it only gives the number of that entry (such as 00146).



VBA Code:
Private Sub UserForm_Activate()

Dim sh As Worksheet

Set sh = ShDA01

Dim lr As Long

Dim x As Long

x = ShDA01.Range("C" & Rows.Count).End(xlUp).Row

lr = ShDA01.Range("C" & Rows.Count).End(xlUp).Row



With Txt_Record



.Value = Format(Val(Range("C" & Rows.Count).End(xlUp)) + 1, "00000")

.Enabled = True



End With

End Sub



I have another box (combo_intake_type) that lists the different types of intakes that the user can choose from. This list is expandable from a list accessed by the user.

I wish for that ID # to show the first two letters of the Intake type (combo_intake_type) that has been chosen. Such as if the user chooses 'Geometry' as the next entry the ID # would be 00147-GE , If 'Mechanical' is chosen next the ID # would be 00148-ME
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
maybe
Format(Val(Range("C" & Rows.count).End(xlUp)) + 1, "00000") & "-" & Left(combo_intake_type, 2)
 
Upvote 0
maybe
Format(Val(Range("C" & Rows.count).End(xlUp)) + 1, "00000") & "-" & Left(combo_intake_type, 2)
it works up to the - but the & Left(combo_intake_type, 2) didn't show up
 
Upvote 0
Well, that was just a guess because you revealed nothing about the combo list.
1 column or more?
What's actually in the column(s)?
You'll get no combo value added to the end if nothing was chosen. What should happen if that's the case?
 
Upvote 0
Well, that was just a guess because you revealed nothing about the combo list.
1 column or more?
What's actually in the column(s)?
You'll get no combo value added to the end if nothing was chosen. What should happen if that's the case?
the combo list is a single column from a dynamic name range 'controls_intake_types' from a table on the worksheet 'controls.general. the user will have access to. Right now, this in 'design' mode so the only values I have in it is 'All',' Geometry' and 'Mechanical' but the user can have whatever and more. If no choice is made in that 'combo_intake_type' the other textboxes on the form will not be visible or enabled. I been thinking the value for that combo_intake_type is after the txt_record in my save data and transfer into the worksheet 'data.all' vba codes. But that investigation is tomorrow night.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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