I am trying to find all customers who have a certain code associated with them.
One worksheet has a list of the customers, with separate columns for each code associated with them.
The second worksheet has a list of codes I'm looking for.
I found code on this forum that I can use to search, but it only searches through one specified column.
I've been trying to get this code to loop through all columns on the spreadsheet, but I'm getting it all twisted and tangled.
In addition, is there a way to use wildcards in the way this search is set up?
For instance, any codes that fall between S00 and S99 are valid.
I've attached a spreadsheet. Thanks for your help.
Last edited by Brandon2013; 06-13-2019 at 12:16 PM.
It would work to simply write "Match" in column B if the row contains any of the items in the search list.
According to your attachment a demonstration as a beginner starter :
PHP Code:
Sub Demo() Dim V2, M$(), V1, R&, C%, S$() V2 = Sheet2.Range("A2", Sheet2.[A1].End(xlDown)).Value2 With Sheet1.UsedRange.Rows("2:" & Sheet1.UsedRange.Rows.Count).Columns ReDim M(1 To .Rows.Count, 0) V1 = .Item(3).Resize(, .Count - 2).Value2 For R = 1 To UBound(V1) For C = 1 To UBound(V1, 2) If IsEmpty(V1(R, C)) Then Exit For S = Split(LTrim(V1(R, C))) If S(0) Like "S##" Or IsNumeric(Application.Match(S(0), V2, 0)) Then M(R, 0) = "Match": Exit For Next Next .Item(2).Value2 = M End With End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
Bookmarks