I have a user form (Userform1) that allows users to select items(max 24 items) from check boxes. (Checkbox1 to checkbox24)
Each check box is linked to a different text box so that users can select more than 1 item.
If checkbox 1 is selected, then textbox 1 = "A"
If checkbox 2 is selected, then textbox 2 = "B" and it goes on like this.
Now these items are available in Small and Medium.
I have a list of all the items and their different prices per size.
Example of My list:
Items Price (Small) Price (Medium)
A 10 15
B 7 12
and it goes on.
I want the userform to pull up the prices of the items based on their sizes.
So that when a user selects item "A" in small - a text box will show the price 10.
I tried:
Private Sub Textbox1_change()
Dim sizes As String
sizes = Me.TextBox1.Value
On Error Resume Next
If textboxsize.Value = "SMALL" Then Me.TextBox25.Value =
application.worksheetfunction.vlookup(sizes, sheets("PRICE
LIST").range("A2:C100000"),2,0)
End If
If textboxsize.Value = "MEDIUM" Then Me.TextBox25.Value =
application.worksheetfunction.vlookup(sizes, sheets("PRICE
LIST").range("A2:C100000"),3,0)
End If
End Sub
It is working but the constraint is that i have to copy the code to every textbox of the userform and change the ids.
Is there any easier way to do this?
Thanks.