title: Excel vba run time error 438 (If Cl.Value Like str And Rng2.Cl.Value <> "" Then)
body: <p>I have a code to copy data from one sheet to another using if and vlookup function but not working </p>
  
  <pre><code>Sub CopyRows()
  Dim Rng As Range
  Dim Cl As Range
  Dim str As String
  Dim RowUpdCrnt As Long
  
  Set UsedRange = Sheets("Jan").Range("b5:Am81")
  Set Rng = Sheets("Jan").UsedRange  'the range to search ie the used range
  Set Rng2 = Sheets("Feb").Range("I5:AK5")
  str = "WRK." 'string to look for
  Sheets("Feb").Range("B5:B81").Value = ""
  
  RowUpdCrnt = 5
  
  ' In my test data, the "WRK."s are in column AN.  This For-Each only selects column AN.
  ' I assume all my "WRK."s are in a single column.  Replace "B" by the appropriate
  ' column letter for your data.
  
  With Sheets("Jan")
  ' loop until last row with data in Column AN (and not the entire column) to save time
    For Each Cl In .Range("AN1:AN" &amp; .Cells(.Rows.Count, "AN").End(xlUp).Row)
      If Cl.Value Like str And Rng2.Cl.Value &lt;&gt; "" Then
      'if the cell contains the correct value copy it to next empty row on sheet 2 &amp;  delete the row
        If Not IsError(Application.Vlookup(.Range("B" &amp; Cl.Row).Value, Sheets("Master").Range("H7:H200"), 1, 0)) Then   ' &lt;-- verify the VLookup was successful
          Sheets("Feb").Range("B" &amp; RowUpdCrnt).Value = Application.Vlookup(.Range("B" &amp; Cl.Row).Value, Sheets("Master").Range("H7:H200"), 1, 0)
          RowUpdCrnt = RowUpdCrnt + 1       
        End If
      End If  
    Next Cl
  End With
  
  Application.CutCopyMode = False
  End Sub
  </code></pre>