title: Linking multiple values in a cell to checkboxes in userform
body: <p>I have the following search code:</p>
  
  <pre><code>Private Sub Search_Click()
  Dim Name As String
  Dim f As Range
  Dim r As Long
  Dim ws As Worksheet
  Dim s As Integer
  Dim FirstAddress As String
  
  Name = surname.Value
  
  With ws
   Set f = Range("A:A").Find(what:=Name, LookIn:=xlValues)
    If Not f Is Nothing Then
     With Me
      firstname.Value = f.Offset(0, 1).Value
      tod.Value = f.Offset(0, 2).Value
      program.Value = f.Offset(0, 3).Value
      email.Value = f.Offset(0, 4).Text
      officenumber.Value = f.Offset(0, 6).Text
      cellnumber.Value = f.Offset(0, 7).Text
      if f.offset(0,5).value = "PACT" then PACT.value = True
  </code></pre>
  
  <p>I want to modify the <code>if f.offset(0,5).value</code>: If I have one single value in a cell then it's easy to pick that one cell, link it to the checkbox and have the checkbox checkmarked. The problem is I have multiple values in the cell.</p>
  
  <p>The values in the column 6 (f.offset(0,5).values) have the names as the checkboxes eg., checkboxes.name &amp; " " so... PACT OTTAWA VANCOUVER MONTREAL TORONTO</p>
  
  <p>This is done through an add command.</p>
  
  <p>So the column 6 can display PACT OTTAWA VANCOUVER or PACT TORONTO or TORONTO depending on which checkboxes are clicked to add in userform.</p>
  
  <p>If I can read and link to the name of the checkboxes and checkmark the ones that are in column 6 then that would work.</p>
  
  <pre><code>if f.offset(0,5).value = "PACT" then PACT.value = True
  </code></pre>
  
  <p>If I do it this way, then I'll have way too many combinations that I have to figure it out using if statements. Is there a way to "read" column 6, match it to the names of checkbox and checkmark the checkboxes in the userform when I click the search button?</p>
  
  <p><strong><em>EDIT:</em></strong> </p>
  
  <pre><code>Private Sub Search_Click()
  Dim Name As String
  Dim f As Range
  Dim r As Long
  Dim ws As Worksheet
  Dim s As Integer
  Dim FirstAddress As String
  Dim str() As String
  
  Name = surname.Value
  
  With ws
   Set f = Range("A:A").Find(what:=Name, LookIn:=xlValues)
    If Not f Is Nothing Then
      With Me
        firstname.Value = f.Offset(0, 1).Value
        tod.Value = f.Offset(0, 2).Value
        program.Value = f.Offset(0, 3).Value
        email.Value = f.Offset(0, 4).Text
        officenumber.Value = f.Offset(0, 6).Text
        cellnumber.Value = f.Offset(0, 7).Text
  
        str() = Split(inputstr, " ")
        For i = 0 To UBound(str)
         Select Case UCase(Trim(str(i)))
          Case "PACT": PACT.Value = True
          Case "PrinceRupert": PrinceRupert.Value = True
          Case "Montreal": Montreal.Value = True
          Case "TET": TET.Value = True
          Case "WPM": WPM.Value = True
          Case "TC": TC.Value = True
          Case "US": US.Value = True
          Case "Other": Other.Value = True
  
         End Select
  
        Next i
  </code></pre>
  
  <p>I've added the following code but nothing happens.</p>
  
  <p>I've searched on msdn but I don't quite understand the str() = split(inputstr, " ") and for I = 0 Ubound (str). I'm assuming the trim function is if after trimming the values of column 6 and case is "PACT" then PACT.value = True?</p>
  
  <p><strong><em>EDIT2:</em></strong></p>
  
  <p>It seems the code doesn't catch the words other than PACT and I'm assuming it picks up PACT because it's the first one. I've tried manually inputting the column 6 values and see if any names get picked up but it doesn't. Is there a way to fix this? </p>
  
  <p>Perhaps it's because when I trim the data in column 6, it's seen as PACTPrinceRupertTETWPMTCUSOther. Is that why it won't pick it up?</p>