Just got some help to create this macro, but in addition to what I have here I'd like the search results to be displayed if the criteria matches part of the contents of a Cell.
for example I might be searching for a project number 'P12345' and the result should still be displayed if the cell contains 'P00001, P12345'
Is there any way to tweak my code to do this?
Thanks for any help!
for example I might be searching for a project number 'P12345' and the result should still be displayed if the cell contains 'P00001, P12345'
Is there any way to tweak my code to do this?
Thanks for any help!
Code:
Sub Search()
Application.ScreenUpdating = False
Dim row_count, myCode
myCode = InputBox("Enter Search Data:", "Search")
With Sheets("Search Results")
.Rows(2 & ":" & .Rows.Count).Delete
End With
For row_count = 1 To Range("A" & Rows.Count).End(xlUp).Row
If Range("A" & row_count) = myCode Or Range("B" & row_count) = myCode Or _
Range("C" & row_count) = myCode Or Range("D" & row_count) = myCode Or _
Range("E" & row_count) = myCode Then
Range("A" & row_count & ":F" & row_count).Copy _
Sheets("Search Results").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
End If
Next
Application.ScreenUpdating = True
Sheets("Search Results").Activate
End Sub