vba auto populate texbox based on criteria

djossh

Board Regular
Joined
Jul 27, 2009
Messages
243
hi. I need to populate my textbox based on criteria (from another textbox).

below is my sample data

(Sheet2)
ABCDE
1133ABCOCT-8-201812.50EEE
2254HDSSEPT-1-201832.50GGG
3456NJHOCT-10-201836.12DDD
4569SDFAUG-21-201825.00UUU
5112JRTJULY-6-201815.00WWW
6684BSSDEC-13-201881.45OOO

<tbody>
</tbody>

RESULT ON MY TEXTBOXES (auto Populate based on the value on my Textbox1)

Textbox1 = SDF (Textbox1 is where i will input the criteria)

Result below:

Textbox2 = AUG-21-2018
Textbox3 = 569
Textbox4 = 25.00
Textbox5 = UUU


Thanks in advance for any help...
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Code:
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] TextBox1_Change()
    [color=darkblue]Dim[/color] v [color=darkblue]As[/color] [color=darkblue]Variant[/color]
    
    TextBox2.Text = ""
    TextBox3.Text = ""
    TextBox4.Text = ""
    TextBox5.Text = ""
    
    [color=darkblue]With[/color] Sheets("Sheet2")
        [color=darkblue]If[/color] TextBox1.Text <> "" [color=darkblue]Then[/color]
            v = Application.Match(TextBox1.Text, .Range("B:B"), 0)
            [color=darkblue]If[/color] IsNumeric(v) [color=darkblue]Then[/color]
                TextBox2.Text = .Range("C" & v).Value
                TextBox3.Text = .Range("A" & v).Value
                TextBox4.Text = .Range("D" & v).Value
                TextBox5.Text = .Range("E" & v).Value
            [color=darkblue]End[/color] [color=darkblue]If[/color]
        [color=darkblue]End[/color] [color=darkblue]If[/color]
    [color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,580
Members
448,972
Latest member
Shantanu2024

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