Hi there I have a problem with vba coding for searching in excel worksheet. My actual code works fine but it searches data from the begining of work sheet rows/cell to the end of work sheet rows/cell. I need to code that it start search from the last row entry to the top of the work sheet. Any help how to modify my code to perform the search from last entry please? this is my actual code:
Dim totRows As Long, i As Long
totRows = Worksheets("sheet1").Range("A1").CurrentRegion.Rows.Count
If TextBox1.Text = "" Then
MsgBox "Enter the File Number"
End If
For i = 2 To totRows
If Trim(Sheet1.Cells(i, 1) <> Trim(TextBox1.Text)) And i = totRows Then
MsgBox "File Not Found!"
End If
thanks
If Trim(Sheet1.Cells(i, 1) = Trim(TextBox1.Text)) Then
TextBox1.Text = Sheet1.Cells(i, 1)
TextBox2.Text = Sheet1.Cells(i, 2)
ComboBox1.SelText = Sheet1.Cells(i, 3)
TextBox3.Text = Sheet1.Cells(i, 4)
TextBox6.Text = Sheet1.Cells(i, 5)
ComboBox3.SelText = Sheet1.Cells(i, 6)
ComboBox2.SelText = Sheet1.Cells(i, 7)
Exit For
End If
Next i
End Sub
Bookmarks