title: If Active Cell Value = Offset Cell Value Then
body: <p>I am trying to use Offset in Excel VBA to determine whether 2 cells are the same value.  The script is rejecting the Offset saying "Sub or Function not defined"</p>
  
  <p>I have searched extensively across a number of Forums without success</p>
  
  <pre><code>Dim b As Integer
  Dim detail As String
  Dim wbk As Workbook
  Dim ws As Worksheet
  
  Set wbk = Workbooks("Commission Statements.xlsm")
  With Workbooks("Commission Statements.xlsm").Sheets("Required Data")
  b = 2
  Do Until IsEmpty(.Cells(b, 1))
  
  'If A2 = A1 AND B2 = B1
  'Copy cells in columns D:M
  'Go to Worksheet named in column A
  'Paste
  If ActiveCell.Value = ActiveCell(Offset(-1)).Value And ActiveCell(Offset(0, 1)).Value = ActiveCell(Offset(-1, 1)).Value Then
  .Range(Cells(b, 4), .Cells(b, 13)).Copy
  detail = .Cells(b, 1).Value
  Sheets(detail).Range("B" &amp; Rows.Count).End(xlUp).Offset(1).PasteSpecial xlValues
  End If
  
  'If A2 = A1 BUT B2 &gt; B1
  'Go to Worksheet named in Column A
  'Copy cells B8:K9
  'Go to bottom line of data in column K
  'Paste
  'Return to Active Cell in "Required Data" Worksheet
  'Copy cells in columns D:M
  'Go to Worksheet named in column A
  'Locate last row of data in column K and offset 1 row
  'Paste
  ElseIf ActiveCell.Value = ActiveCell(Offset(-1)).Value And ActiveCell(Offset(0, 1)).Value &gt; ActiveCell(Offset(-1, 1)).Value Then
  detail = .Cells(b, 1).Value
  ws.Range("B8:K9").Copy
  Range("" &amp; Rows.Count).End(xlUp).Offset(3).PasteSpecial xlPasteValues
  ws.Activate "Required Data"
  Range(Cells(b, 4), .Cells(b, 13)).Copy
  detail = .Cells(b, 1).Value
  Sheets(detail).Range("B" &amp; Rows.Count).End(xlUp).Offset(1).PasteSpecial xlValues
  
  b = b + 1
  
  Loop
  End With
  End Sub
  </code></pre>
  
  <p>Each cell value in column A has an associated Worksheet to which I need to paste.
  What I am seeking is as shown indented in the code.  There are 2 possible scenarios:</p>
  
  <ul>
  <li>cell in A = cell (offset(-1)) AND cell in B = cell (offset(-1)</li>
  </ul>
  
  <p>or:</p>
  
  <ul>
  <li>cell in A = cell (offset(-1)) AND cell in B &lt;> cell (offset(-1)</li>
  </ul>