title: Multiple sheets object error in vba code
body: <p>I am having an issue with a "Run-time error '1004': Application-defined or object-defined error.  My if then statement is not recognizing one of the objects being compared  please help me to understand what I am doing wrong.</p>
  
  <pre><code>Sub Enter_deposits()
  
      Sheets("Deposits").Activate
  
      Dim x As Integer
      Dim y As Integer
  
  
      For x = 4 To 21
          For y = 10 To 500
              If Sheets("deposits").Range(2, 4).Value = Sheets((Cells(x, 14).Value)).Range(y, 2).Value _
                      And Sheets((Cells(x, 14).Value)).Range(y - 1, 3) = 0 _
                      And Sheets("deposits").Range(x, 15).Value &lt;&gt; Sheets((Cells(x, 14).Value)).Range(y, 3) Then
  
                  Sheets("deposits").Range(x, 15).Copy
                  Sheets((Cells(x, 14).Value)).Range(y, 3).PasteSpecial xlPasteValues
  
              Else
  
              End If
          Next y
      Next x
  End Sub
  </code></pre>