hello guys, I am in a bind here at work. I'm not very good at using VBA macros and have been assigned a project that deals with searching through various spreadsheets using userform that has textboxes and checkboxes. What I am trying to do is type a value in textbox1, for example, and it searches the sheet for that value in column 1 and only populates the sheet with rows that have the value I typed in the textbox1. If that value doesn't exist or is wrong, i want it to say no match found. Same goes for the next textbook, which will actually be looking through a different column within the spreadsheet but once the textbook value matches the ones on the spreadsheet, i want it to populate it with those rows that have that value. I have the command buttons down (search, cancel, etc), the part i am stumped on is the textbox. The code I have is as follows below for the first textbox, but it does not work fully. Also, how would I continue the code with the second texbox search function without it interfering with the first?
'Private Sub CommandButtonOk_Click()
Sheet4.Activate
Dim Found As Range
Set Found = Sheets("Sheet4").Range("A:A").Find(What:=Me.TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Found Is Nothing Then
MsgBox "No match for " & Me.TextBox1.Value, , "No Match Found"
Else
Found.Offset(0, 1).Value = TextBox2.Value
End If
End Sub
Bookmarks