application defined or object defined error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, VB Novice so please don't laugh at the code!

I keep getting Run time error "Application-defined or object-defined error"
with the following line " If Cells(irisk, 20).Value = ("Internal") Then" in
the code below. I imagine it is related to the way I am defining the Value
as a string. (I am trying to search down column T and remove all rows that
contain the word "internal" in columnT. Can anyone tell me what I'm doing
wrong please?

'<==========
ActiveWorkbook.Sheets("Customer Risk Log").Select
Dim lastriskrow As Long, irisk As Long
lastriskrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastriskrow To 2 Step -1
If Cells(irisk, 20).Value = ("Internal") Then
Rows(irisk).Delete
End If
Next
'<==========

Thanks,

Nick
 
You are looping on i, so you want something like


If Cells(i, 20).Value = "Internal" Then
Rows(i).EntireRow.Delete
 
that did the trick, thank you.

Gary''s Student said:
You are looping on i, so you want something like


If Cells(i, 20).Value = "Internal" Then
Rows(i).EntireRow.Delete
 
Back
Top