title: Compile Error: Object Required VBA
body: <p>I'm new to VBA. I'm trying to write a script that cleans up some data from an experiment. I keep getting an error saying "Object Required" and it highlights pold. Does anyone have any idea why? </p>
  
  <p>As for the script, I'm trying to go down a column of participant numbers and map out what range each participant is in. There are around 30 lines per participant, and I want to define that as values in an array. </p>
  
  <pre><code>Sub Cleanthismofoup() 
  Dim pranges(1 To 50) As Long 
  Dim pbegin As Range
  Dim pend As Range
  Dim pold As Integer
  Dim pnew As Integer
  Dim pcell As Range
  Dim pcounter As Long
  Dim i As Long
  
  Set pcell = Range("A1:A1")
  Set pbegin = Range("A2:A2")
  Set pold = Range("B2:B2").Value
  pcounter = 0
  
  'for every item, store value in pnew
  ' move down one line. Check pnew = pold
  ' if it is, do again. else create new range
  
  For i = 1 To rngl
  pcell = pcell.Offset(-1, 0)
  pnew = pcell.Cells.Value
  If pnnew &lt;&gt; pold Then pcell = pend
  If pcell = pend Then
  counter = counter + 1
  pranges(counter) = pbegin
  counter = counter + 1
  pranges(counter) = pend
  pbegin = pcell.Offset(-1, 0)
  Else: pold = pnew
  End If
  
  i = i + 1
  Next
  </code></pre>
  
  <p>End Sub</p>