I have code that loops through a column of names on Sheet("TeeAssign"), and if certain criteria are met, the name is added to my string called IDs. I then end up with a string that looks like this:
: IDs : ",Hartman,Anderson,Nelson,Peterson,Jones,Lee" : String
I then switch to Sheet("Groupings") and want to check to see if any of the names in IDs are also in a column on worksheet #2.
My problem is that when I get the names from the Groupings worksheet they are in quotation marks (being a string), which does not match what is in IDs. How best to do a work-around?
: IDs : ",Hartman,Anderson,Nelson,Peterson,Jones,Lee" : String
I then switch to Sheet("Groupings") and want to check to see if any of the names in IDs are also in a column on worksheet #2.
My problem is that when I get the names from the Groupings worksheet they are in quotation marks (being a string), which does not match what is in IDs. How best to do a work-around?
VBA Code:
Sheets("TeeAssign").Select
LastPlayer = Cells(Rows.Count, 7).End(xlUp).Row
For i = 2 To LastPlayer
If Cells(i, 9).Value = 0 Then
IDs = IDs & "," & Cells(i, 7)
End If
Next i
If Len(IDs) Then
IDs = Mid(IDs, 2)
End If
Sheets("Groupings").Select
lgroupingPlayer = Cells(Rows.Count, 2).End(xlUp).Row
For i = 2 To lgroupingPlayer
ckVal = Cells(i, 2).Value
If InStr(ckVal, IDs) > 0 Then
Debug.Print ckVal
End If
Next i
End Sub
Last edited by a moderator: