InStr hampered by quotation marks

Sheridi

Board Regular
Joined
Nov 20, 2015
Messages
76
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?

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:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
If you are trying to see if ckVal is in IDs, then it should be
VBA Code:
         If InStr(IDs, ckVal) > 0 Then
 
Upvote 0
Solution
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,050
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top