LikeButtah1
New Member
- Joined
- Apr 17, 2018
- Messages
- 34
Here is the code I'm using to search for a Last Name and return the entire row of values into separate boxes on a user form. When I type the Last Name into the text box to search it must be with the Upper case first letter because if I don't capitalize the Last Name excel doesn't recognize it and nothing gets returned into the text boxes. Is there a way in vba to ignore whether or not the Last Name has a capitalized first letter. Thanks in advance.
Code:
Private Sub btnLName_Click()
blnNew = False
txtLastName.Text = ""
txtFirstName.Text = ""
txtC.Text = ""
txtNewCard.Text = ""
txtAccDes.Text = ""
txtAccCreated.Text = ""
txtAccGranted.Text = ""
txtAccCancelled.Text = ""
txtAccCategory.Text = ""
txtNotes.Text = ""
TRows = Worksheets("PNG Database").Range("A1").CurrentRegion.Rows.Count
For i = 3 To TRows
If Worksheets("PNG Database").Cells(i, 1).Value = TextBox1.Text Then
txtLastName.Text = Worksheets("PNG Database").Cells(i, 1).Value
txtFirstName.Text = Worksheets("PNG Database").Cells(i, 2).Value
txtC.Text = Worksheets("PNG Database").Cells(i, 3).Value
txtNewCard.Text = Worksheets("PNG Database").Cells(i, 4).Value
txtAccDes.Text = Worksheets("PNG Database").Cells(i, 5).Value
txtAccCreated.Text = Worksheets("PNG Database").Cells(i, 6).Value
txtAccGranted.Text = Worksheets("PNG Database").Cells(i, 7).Value
txtAccCancelled.Text = Worksheets("PNG Database").Cells(i, 8).Value
txtAccCategory.Text = Worksheets("PNG Database").Cells(i, 9).Value
txtNotes.Text = Worksheets("PNG Database").Cells(i, 12).Value
Exit For
End If
Next i
End Sub