title: Excel VBA If cell.value = .. then Range(selection).offset().value issue
body: <p>I am getting an error on the code below:</p>
  
  <pre><code>For Each cell In Range("H2", Selection.End(xlDown).End(xlDown).End(xlUp)).SpecialCells(xlCellTypeVisible)
  If cell.Value = Range(Sheets("Mapping").Cells(4, x)).Value Then
  Range(Selection).Offset(0, -7).Value = "=IF(LEFT(RC9,8)=Mapping!R8C1,""YES"",""NO"")"
  Else
  End If
  </code></pre>
  
  <p>This is part of a larger code where I am trying to have each visible cell in Column H compared to a cell on the mapping sheet and if correct then the if statement will be added into column A.</p>
  
  <p>I am having a similar issue when attempting to use cell.value in another if statement where I include an AND statement, see below. Same type of FOR statement for Column I in this case. Comparing each value in column I to two different cells on the mapping sheet and if correct the changing column A's value to YES. Both lines break on the 3rd line and the second code breaks on the second line as well.</p>
  
  <pre><code>For Each cell In Range("I2", Selection.End(xlDown).End(xlDown).End(xlUp)).SpecialCells(xlCellTypeVisible)
  If cell.Value = Range(Sheets("Mapping").Cells(4, x)).Value And cell.Value = Range(Sheets("Mapping").Cells(9, 1)).Value Then
  Range(Selection).Offset(0, -7).Value = "YES"
  Else
  'do nothing
  </code></pre>
  
  <p>Any help would be greatly appreciated.
  Thanks.</p>