title: In called subroutines, getting an "object required" error when reading cells
body: <p>My project includes reading data out of multiple different workbooks in a folder using a Macro in an unused workbook. I have been defining exactly which workbook to pull information from, and that is working fine so far. However, my procedure got to be too large, so I now have a few subroutines at the bottom that I call in the middle of my process. When I call this, I get an "object required" error. Here are the relevant clips:</p>
  
  <pre><code>Sub LoopFiles()
  Dim MyFileName, FilenameNew, MyPath As String
  Dim wb1 As Workbook
  
  MyPath = "C:\ExcelT2\"
  MyFileName = Dir(MyPath &amp; "*.csv")
  
  Do Until MyFileName = ""
      Set wb1 = Workbooks.Open(MyPath &amp; MyFileName)
  
  With wb1
  
      .Sheets.Add After:=.Worksheets(.Worksheets.Count)
      .Sheets.Add After:=.Worksheets(.Worksheets.Count)
  
      wb1.Worksheets(1).Select
  
      For i = 17 To 5000
  
          ElseIf wb1.Worksheets(1).Cells(i, 3) &lt;&gt; wb1.Worksheets(1).Cells((i - 1), 3) Then
              cn = cn + 1
              prevval = prevval + 1
  
              Call One_Wep
  '......
  
          End If
      End With
  Loop
  
  End Sub
  
  Private Sub One_Wep()
          If wb1.Worksheets(1).Cells(i, 1) = 1 And wb1.Worksheets(1).Cells((i + 3), 1) = 11 And wb1.Worksheets(1).Cells(i, 3) = wb1.Worksheets(1).Cells((i + 3), 3) And wb1.Worksheets(1).Cells((i + 2), 6) &lt;&gt; 57 Then
              OneWep = 1
  
  '......
          End If
  End Sub
  </code></pre>
  
  <p>The error occurs on the If statement shown under One_Wep. I think it might have to do with referencing wb1 in the called function, but after looking around I can't figure out how to solve this. Thanks in advance!</p>