PDA

View Full Version : [SOLVED] VBA - Determine cell value of specific column and row in userform



tarekgemayel
07-20-2014, 12:37 AM
Please refer to this attachment 11994.

I have a userform where you can pick a Customer from a drop down list and also a product from a drop down list.
Depending on the customer and product chosen, a Discount must be applied.

That specific discount is located on sheet "Customers" in a table whose rows are the Customers and columns are the Products.

Once I have chosen the customer and the product, how can I extract the discount matching my selection?

Please refer to the attached excel file and fill in the code in the section indicated.
Thank you all :)

HaHoBe
07-20-2014, 01:26 AM
Hi, tarekgemayel,

try it like this:

Private Sub ProductBox_Change()
On Error GoTo Error_Error

'Update Discount depending on selected Customer and Selected Product
'''''INSERT CODE HERE
DiscountBox.Text = Worksheets("customers").Cells(CustomerBox.ListIndex + 2, ProductBox.ListIndex + 2).Value
''''END OF CODE HERE
On Error GoTo 0
Exit Sub

Error_Error:
MsgBox "Error when updating Discount"

End Sub
Ciao,
Holger

tarekgemayel
07-20-2014, 01:38 AM
ahhhhhh. So there is in fact a Property that serves this purpose. lol :banghead:
Finally :)

Thanks a lot buddy.