0

I have a list of about 3000, i am using the below word find to pick out the term "Incoterm tariff C" and delete a big section of blank data. (via column A)

When running the below it will stop at about line 350, and spit out an error message "Run Time 13, Type mismatch". It stops on the highlighted line below. Why?

Sub wordfind()

LastRow = Cells(Rows.Count, 1).End(xlUp).Row

For I = LastRow To 1 Step -1
   If Range("A" & I).Value = "Incoterm   Tariff C" Then ' error occurs here
      Range("A" & I).Select
      Selection.EntireRow.delete
      ActiveCell.Offset(-13).Select
     ActiveCell.Resize(12).Select
      Selection.EntireRow.delete
   End If
 Next I

End Sub
  • it did a little more this time. fot stuck on A296, contains the phrase "Hawb Org Dst" dont know why, it should skip over this line seeking the next "Incoterm tariff C" line checked the incoterm line before it, and after, which is fine.
Community
  • 1
  • 1
  • 1
    Ok, I have a question for you. It's really completely out of left field and thinking outside the box, but here it goes: *Have you looked to see what's in that cell?* – Jean-François Corbett Sep 09 '14 at 09:11
  • Also a much better way to achieve what you want is using [AUTOFILTER](http://stackoverflow.com/questions/11631363/how-to-copy-a-line-in-excel-using-a-specific-word-and-pasting-to-another-excel-s) – Siddharth Rout Sep 09 '14 at 09:16
  • BTW you may be getting that error because your cell probably has a #Formula Error like #NA or #Value or #Div etc... ;) – Siddharth Rout Sep 09 '14 at 09:17
  • Yep, looked in the cell, cant see anything wrong. The data in the cells is converted from a .txt file. no formulas or anything. – Nigel Cheshire Sep 09 '14 at 09:51
  • What exact text is in the cell? – Rory Sep 09 '14 at 10:22

1 Answers1

0

Replace:

If Range("A" & I).Value = "Incoterm   Tariff C" Then

with:

If Range("A" & I).Text = "Incoterm   Tariff C" Then
Gary's Student
  • 95,722
  • 10
  • 59
  • 99