title: VBA Excel: How to check if a value is in a selected range of values (or current cell)
body: <p>I have a reference set of data in a column of cells (it could have been a row, but whatever).</p>
  
  <p>I want to go through several worksheets, checking a selected range of values and if the current cell value is in the reference data, use it as the value to paste into an Offset of the next series of cells until the current cell has changed to some new value in the reference data, at which time the paste process should repeat for the new value and next series of cells.
  e.g.</p>
  
  <pre><code>Sub doStuff()
  Dim RefRange As Range, queryRange As Range, checkCell As Rnage
  String pasteDate As String
  
  Set RefRange = Range("A1:A50")
  Set queryRange = .Selected
  
  For Each checkCell In queryRange
    If checkCell.Value IN RefRange &lt;***here's where I don't know what to use ***&gt;
       pasteData = checkCell.Value
       ' Advance to next item
       Next
    ElseIf checkCell.Value Not In queryRange &lt;***here's where I don't know what to use ***&gt;
       ActiveCell.Offset(0,+1).Value = pasteData
    End If
  Next
  End Sub
  </code></pre>
  
  <p>I know how to do this in SQL, is there some similar method in VBA?</p>
  
  <p>In SQL:</p>
  
  <pre><code>Select a, b from table where c in ('foo', 'bar', 'baz') OR
  
  Select a, b from table where c in (select e from some_other_table)
  </code></pre>
  
  <p>TIA</p>