match data based on three combobox & three columns and populate values into textbox

leap out

Active Member
Joined
Dec 4, 2020
Messages
271
Office Version
  1. 2016
  2. 2010
hi
I have many comboboxes and three comboboxes . each three comboboxes linked with COL A,B,C when select the items for each three comboboxes should populate the values in textbox
useform



1.PNG


sheet LIST

msg.xlsm
ABCD
1BRANDTYPEORIGINQUANTITY
220-W50 208LQ8EU300
320-W50 12x1LQ8EU400
420-W50 15x1LQ8EU500
520-W50 12x1LCASST600
620-W50 15x1LCASST700
710-W40 208LENIIT800
810-W40 208LCASST900
910-W40 208LQ8EU250
list
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try this:

VBA Code:
Private Sub CommandButton1_Click()
  Dim a As Variant
  Dim i As Long
  
  a = Sheets("list").Range("A2", Sheets("list").Range("D" & Rows.Count).End(3)).Value
  For i = 1 To UBound(a)
    If a(i, 1) = ComboBox1 And a(i, 2) = ComboBox2 And a(i, 3) = ComboBox3 Then TextBox1 = a(i, 4)
    If a(i, 1) = ComboBox4 And a(i, 2) = ComboBox5 And a(i, 3) = ComboBox6 Then TextBox2 = a(i, 4)
  Next
End Sub
 
Upvote 0
exactly this is what I want . just I would add messge box if I choose the items for each three combox if thy are not matched with COL A,B,C then show message"the items are not matched, please try again"
 
Upvote 0
Try :

VBA Code:
Private Sub CommandButton1_Click()
  Dim a As Variant
  Dim i As Long
  
  TextBox1 = ""
  TextBox2 = ""
  a = Sheets("list").Range("A2", Sheets("list").Range("D" & Rows.Count).End(3)).Value
  For i = 1 To UBound(a)
    If a(i, 1) = ComboBox1 And a(i, 2) = ComboBox2 And a(i, 3) = ComboBox3 Then TextBox1 = a(i, 4)
    If a(i, 1) = ComboBox4 And a(i, 2) = ComboBox5 And a(i, 3) = ComboBox6 Then TextBox2 = a(i, 4)
  Next
  If TextBox1 = "" Then MsgBox "For textbox1. The items are not matched, please try again"
  If TextBox2 = "" Then MsgBox "For textbox2. The items are not matched, please try again"
End Sub
 
Upvote 0
Solution
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,036
Members
449,205
Latest member
Eggy66

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