Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hi i have the code below where it does a search but it will only let me enter numbers in the textbox and not letters, but i want to be able to input both numbers and letters can you help please, i am very new to VBA and still learning, i have searched for the answer alot on internet with no success so far, really hope you can help me.
Code:
Sub GetData()
If IsNumeric(UserForm1.TextBox1.Value) Then
flag = False
i = 0
id = UserForm1.TextBox1.Value
Do While ThisWorkbook.Worksheets("Sheet2").Cells(i + 1, 1).Value <> ""
If ThisWorkbook.Worksheets("Sheet2").Cells(i + 1, 1).Value = id Then
flag = True
For j = 2 To 3
UserForm1.Controls("TextBox" & j).Value = ThisWorkbook.Worksheets("Sheet2").Cells(i + 1, j).Value
Next j
End If
i = i + 1
Loop
If flag = False Then
For j = 2 To 3
UserForm1.Controls("TextBox" & j).Value = ""
Next j
End If
Else
ClearForm
End If
End Sub
Last edited by a moderator: