rmac1954

New Member
Joined
Sep 28, 2017
Messages
9

I created a userform with 10 comboboxes 1 - 10 which populate with part numbers, with corresponding txt_qty boxes 1 - 10 which populate with ordeer quantities.

I want to search on the part number in "ComboBox1" and then store the quantity from txt_Qty1 into a cell in the column named "Order Qty".

I am able to loop through the comboboxes 1 through 10 with the following code:


Rich (BB code):
Rich (BB code):
Dim cmb As combobox, i As Integer

For i = 1 To 10


Set cmb = Me.Controls.Item("ComboBox" & i)


The problem is that I always get the quantity from txt_qty1. I haven't been able to figure a way to loop through the text boxes in conjunction with the comboboxes. I want qty1 with combobox1 and qty2 with combobox2 and so on.

Rob
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
FYI I got the error when I tried duplicated the above code as such:

Code:
Dim cmb As combobox, i As Integer
Dim pqty As TextBox, i As Integer


For i = 1 To 10


Set cmb = Me.Controls.Item("ComboBox" & i)
Set pqty = Me.Controls.Item("txt_qty" & i)
 
Upvote 0
Try
Code:
Dim cmb As combobox
Dim pqty As TextBox
Dim i As Long
These days there is no benefit to declaring something as Integer, as its converted to Long when compiled
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,047
Members
448,940
Latest member
mdusw

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