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)
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]133[/TD]
[TD]ABC[/TD]
[TD]OCT-8-2018[/TD]
[TD]12.50[/TD]
[TD]EEE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]254[/TD]
[TD]HDS[/TD]
[TD]SEPT-1-2018[/TD]
[TD]32.50[/TD]
[TD]GGG[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]456[/TD]
[TD]NJH[/TD]
[TD]OCT-10-2018[/TD]
[TD]36.12[/TD]
[TD]DDD[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]569[/TD]
[TD]SDF[/TD]
[TD]AUG-21-2018[/TD]
[TD]25.00[/TD]
[TD]UUU[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]112[/TD]
[TD]JRT[/TD]
[TD]JULY-6-2018[/TD]
[TD]15.00[/TD]
[TD]WWW[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]684[/TD]
[TD]BSS[/TD]
[TD]DEC-13-2018[/TD]
[TD]81.45[/TD]
[TD]OOO[/TD]
[/TR]
</tbody>[/TABLE]

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

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
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,224,755
Messages
6,180,751
Members
452,996
Latest member
nelsonsix66

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