Auto-fill Textbox based on Selection from Multiple Combobox

aroig07

New Member
Joined
Feb 26, 2019
Messages
42
Hi !!

I have this code I have been using which fills up a textbox dependent on a selection from a combobox. Currently I have been trying to modify it to be able to fill the textbox based on the selection from the combination of 2 or more comboboxes. For example, if I have:

ComboBox1 = First Name
ComboBox2 = Last Name

and from those two combobox I want to automatically fill my textbox

TextBox1 = Account#

Here is the code I have up until now, it does not debug or come with error, but it does not fill my textbox with anything.

Private Sub ComboBox9_Change()
'Automatically input job name based on the client, account #, and sub-account # entered
Dim i As Long
Dim LastRow As Long
Dim ws As Worksheet


Set ws = Sheets("Recurrent Job Trail")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row

For i = 2 To LastRow
If ws.Cells(i, "B").Value = (Me.ComboBox1) And ws.Cells(i, "C").Value = (Me.ComboBox8) And ws.Cells(i, "D").Value = (Me.ComboBox9) Or _
ws.Cells(i, "B").Value = Val(Me.ComboBox1) And ws.Cells(i, "C").Value = Val(Me.ComboBox8) And ws.Cells(i, "D").Value = Val(Me.ComboBox9) Then
Me.TextBox8 = ws.Cells(i, "A").Value
End If
Next i


End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Your code works for me and updates the textbox
Therefore the values in your comboboxes and cells are not matching up

What type of values are in each of Columns B, C & D?
What type of values are in each of Comboboxes 1,8 & 9?
How are the values in comboboxes changed (dropdown? manual typing? by code?)
 
Last edited:
Upvote 0
ComboBox1 is the Client Name
ComboBox8 is the Account
ComboBox9 is the Sub Account

The order the are selecting, which is selected using a dropdown, first the client name (CB1 - Column B) then the account (CB8 - Column C) and then the sub (CB9 - Column D. I have the combobox set to filter based on each selection made along the way. Once they select the client the accounts are filtered only to those accounts pertaining to that client, and once they select the account the sub accounts are filtered only to those sub accounts pertaining to those accounts. After they select the sub account the job name (TB8 - Column A) should fill up automatically, but it is not doing so.
 
Upvote 0
ComboBox1 is the Client Name = alpha ?
ComboBox8 is the Account = alpha, numeric or alphanumeric ?
ComboBox9 is the Sub Account = alpha, numeric or alphanumeric ?
 
Last edited:
Upvote 0
ComboBox1 is the Client Name = alpha
ComboBox8 is the Account = numeric
ComboBox9 is the Sub Account = numeric
 
Upvote 0
One problem with numeric values is leading zeros

as a number
0123 = 123

as text
0123 NOT EQUAL 123

Q1 Is Account number always the SAME number of digits ? How many ?
Q2 Can it begin with zero ?

Q3 Is Sub-Account number always the SAME number of digits ? How many ?
Q4 Can it begin with zero ?


 
Upvote 0
The account numbers range from 0 to 284, the accounts that are not 0 do not begin with a leading 0 just the account with 0 as a number.
The sub accounts are the same as accounts, but range from 0 to 600.
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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