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
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