Struggling with code modified to delete invalid rows..

J

jeremiah

I have just one thing that is stumping me. I have modified Ron Debruin code
to go
accross multiple columns but there are certain columns that I get a Run Time
Error 13, Type Mismatch error on. I have column A through K, which are just
general numbers, about every other column has up to 2 decimal places. Those
columns with decimals are where I am getting the run time error. If I do not
incorporate those columns, then the macro runs perfectly.

Sub Loop_Example4()
Dim Firstrow As Long
Dim LastRow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim rng As Range
Dim rngColour As Range
Dim blnColour As Boolean

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet

.Select

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

.DisplayPageBreaks = False

Firstrow = 2
LastRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

For Lrow = LastRow To Firstrow Step -1

If .Cells(Lrow, "c").Value <> "No" And _
.Cells(Lrow, "e").Value <> "No" And _
.Cells(Lrow, "g").Value <> "No" And _
.Cells(Lrow, "i").Value <> "No" And _
.Cells(Lrow, "j").Value <> "No" And _
.Cells(Lrow, "k").Value <> "No" Then .Rows(Lrow).Delete

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub
 
D

Dave Peterson

You can get that kind of error if the cell contains an error.

But since you're looking for "No", you could look for .text instead of .value.

But I'm confused about the numbers comment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top