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
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Status
Not open for further replies.

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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