Hello Everyone! Hope you all are fine.
First, I want to apologize if there's already a thread about this subject, I searched a lot and didn't found anything that could help me with my problem.
So, I'm trying to use VBA userform to look for two criterias from my worksheet.
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD="align: center"]A1[/TD]
[TD="align: center"]A2[/TD]
[TD="align: center"]A3[/TD]
[/TR]
[TR]
[TD="align: center"]Product[/TD]
[TD="align: center"]Flavor[/TD]
[TD="align: center"]Price[/TD]
[/TR]
[TR]
[TD]Ice Cream[/TD]
[TD]Chocolate[/TD]
[TD]5 BRL[/TD]
[/TR]
[TR]
[TD]Ice Cream[/TD]
[TD]Strawberry[/TD]
[TD]6 BRL[/TD]
[/TR]
[TR]
[TD]Popsicle[/TD]
[TD]Grape[/TD]
[TD]2 BRL[/TD]
[/TR]
[TR]
[TD]Popsicle[/TD]
[TD]Vanilla[/TD]
[TD]2,50 BRL[/TD]
[/TR]
</tbody>[/TABLE]
So, what I'm trying to do is a userform that look for both information (Product and Flavor) typed by the customer, like this (It's in portuguese, but it won't confuse you):
But when I type to search any product/flavor that ISN'T the first item of the list, it doesn't find and says that it was unable to get the Index property...
I'm using this code:
Thanks in advance.
First, I want to apologize if there's already a thread about this subject, I searched a lot and didn't found anything that could help me with my problem.
So, I'm trying to use VBA userform to look for two criterias from my worksheet.
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD="align: center"]A1[/TD]
[TD="align: center"]A2[/TD]
[TD="align: center"]A3[/TD]
[/TR]
[TR]
[TD="align: center"]Product[/TD]
[TD="align: center"]Flavor[/TD]
[TD="align: center"]Price[/TD]
[/TR]
[TR]
[TD]Ice Cream[/TD]
[TD]Chocolate[/TD]
[TD]5 BRL[/TD]
[/TR]
[TR]
[TD]Ice Cream[/TD]
[TD]Strawberry[/TD]
[TD]6 BRL[/TD]
[/TR]
[TR]
[TD]Popsicle[/TD]
[TD]Grape[/TD]
[TD]2 BRL[/TD]
[/TR]
[TR]
[TD]Popsicle[/TD]
[TD]Vanilla[/TD]
[TD]2,50 BRL[/TD]
[/TR]
</tbody>[/TABLE]
So, what I'm trying to do is a userform that look for both information (Product and Flavor) typed by the customer, like this (It's in portuguese, but it won't confuse you):
But when I type to search any product/flavor that ISN'T the first item of the list, it doesn't find and says that it was unable to get the Index property...
I'm using this code:
Code:
Private Sub CommandButton1_Click()
Dim produto As String
Dim Sabor As String
produto = TextBox1.Text
Sabor = TextBox2.Text
TextBox3 = "R$" & Application.WorksheetFunction.Index(Range("C2:C5"), _
Application.WorksheetFunction.Match(produto, Range("A2:A5"), 0), _
Application.WorksheetFunction.Match(Sabor, Range("B2:B5"), 0))
End Sub
Thanks in advance.