I have a Textbox that I want autopopulated from a worksheet, based on the values in two other textboxes.
My worksheet has (3) columns: A (Yardage), B (Combinations), C (Price Per Yard).
If TextBox1 = 4,000yds and TextBox2 = 2combinations, then TextBox3 should be populated with $2.80.
The below formula always returns "Not found in database"
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim rng As Range, rng1 As Range, res As Variant
Set rng = Worksheets("Worksheet1").Range("A2:C50").Columns(1)
res = Application.Match(TextBox3.Text, rng, 0)
If Not IsError(res) Then
Set rng1 = rng(res)
TextBox1.Text = rng1.Offset(0, 1)
TextBox2.Text = rng1.Offset(0, 2)
Else
MsgBox "Not found in database"
End If
End Sub
Thanks for your help!
My worksheet has (3) columns: A (Yardage), B (Combinations), C (Price Per Yard).
If TextBox1 = 4,000yds and TextBox2 = 2combinations, then TextBox3 should be populated with $2.80.
The below formula always returns "Not found in database"
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim rng As Range, rng1 As Range, res As Variant
Set rng = Worksheets("Worksheet1").Range("A2:C50").Columns(1)
res = Application.Match(TextBox3.Text, rng, 0)
If Not IsError(res) Then
Set rng1 = rng(res)
TextBox1.Text = rng1.Offset(0, 1)
TextBox2.Text = rng1.Offset(0, 2)
Else
MsgBox "Not found in database"
End If
End Sub
Thanks for your help!