Auto-fill Textbox based on Selection from Multiple Combobox

aroig07

New Member
Joined
Feb 26, 2019
Messages
35
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
 

Some videos you may like

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,770
Office Version
  1. 365
Platform
  1. Windows
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:

aroig07

New Member
Joined
Feb 26, 2019
Messages
35
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.
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,770
Office Version
  1. 365
Platform
  1. Windows
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:

aroig07

New Member
Joined
Feb 26, 2019
Messages
35

ADVERTISEMENT

ComboBox1 is the Client Name = alpha
ComboBox8 is the Account = numeric
ComboBox9 is the Sub Account = numeric
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,770
Office Version
  1. 365
Platform
  1. Windows
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 ?


 

aroig07

New Member
Joined
Feb 26, 2019
Messages
35
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,353
Messages
5,528,197
Members
409,807
Latest member
nicky736

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top