Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
Code:
Private Sub cmdbtnSearch_click()
Dim totRows As Long, i As Long
totRows = Worksheets("Sheet5(Slat)").Range("C3").CurrentRegion.Rows.Count
For i = 3 To totRows
If Trim(Sheet5.Cells(i, 3)) = Trim(TextBox1.Text) Then
TextBox1.Text = Sheet5.Cells(i, 3)
TextBox2.Text = Sheet5.Cells(i, 4)
TextBox3.Text = Sheet5.Cells(i, 5)
TextBox4.Text = Sheet5.Cells(i, 6)
Exit For
End If
Next i
End Sub
I not exactly sure what is wrong with this code. I found this code from a youtube video
http://www.youtube.com/channel/UC-vzNYU9x8IYPk_r89mGvXA
This video is 11 minutes and 24 seconds long. However, the above code ends at 5 minutes and 53 seconds. I had to change some things to fit my project. I typed everything he did. So I'm not certain what I did wrong. When I click on Debug the following line of code is highlighted:
Code:
totRows = Worksheets("Sheet5(Slat)").Range("C3").CurrentRegion.Rows.Count