VB Get the last 3 digit number

Status
Not open for further replies.

Bogz17

New Member
Joined
Feb 19, 2019
Messages
11
Hi guys

i have a problem about my userform i have 16 textbox and command button to search in textbox 1.

is it possible to search only the last 3 digit number in textbox1 instead of 8?



here is my code for my command button
:):):)

Dim totRows As Long, i As Long


totRows = Worksheets("Sheet1").Range("A1").CurrentRegion.Rows.Count


If TextBox1.Text = "" Then
MsgBox "Enter the LHID you wish to search!"
End If




For i = 2 To totRows


If Trim(Sheet1.Cells(i, 1)) <> Trim(TextBox1.Text) And i = totRows Then
MsgBox "LHID not found!"
End If


If Trim(Sheet1.Cells(i, 1)) = Trim(TextBox1.Text) Then


TextBox1.Text = Sheet1.Cells(i, 1)
TextBox2.Text = Sheet1.Cells(i, 2)
TextBox3.Text = Sheet1.Cells(i, 3)
TextBox4.Text = Sheet1.Cells(i, 4)
TextBox5.Text = Sheet1.Cells(i, 5)
TextBox6.Text = Sheet1.Cells(i, 6)
TextBox7.Text = Sheet1.Cells(i, 7)
TextBox8.Text = Sheet1.Cells(i, 8)
TextBox9.Text = Sheet1.Cells(i, 9)
TextBox10.Text = Sheet1.Cells(i, 10)
TextBox11.Text = Sheet1.Cells(i, 11)
TextBox12.Text = Sheet1.Cells(i, 12)
TextBox13.Text = Sheet1.Cells(i, 13)
TextBox14.Text = Sheet1.Cells(i, 14)
TextBox15.Text = Sheet1.Cells(i, 15)
TextBox16.Text = Sheet1.Cells(i, 16)
Exit For
End If


Next i





wish someone can help me
 

Some videos you may like

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.
Status
Not open for further replies.

Watch MrExcel Video

Forum statistics

Threads
1,122,230
Messages
5,594,952
Members
413,954
Latest member
mrsandy

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
Top