Easy one

  • Thread starter Thread starter Lawson
  • Start date Start date
L

Lawson

heres an easy one for y'all:

i have values in columns b and c from rows 5 to 600. i
would like a program that checks each row such that if
the value in column b is greater than column c, it
deletes the values in that row (or deletes the row
entirely)

ill give you a better challenge next time, i swear...
 
Try this one Lawson for the ActiveSheet

Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 6
EndRow = 600
For Lrow = EndRow To StartRow Step -1
If .Cells(Lrow, "B").Value > .Cells(Lrow, "C").Value _
Then .Rows(Lrow).Delete
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
 
-----Original Message-----
heres an easy one for y'all:

i have values in columns b and c from rows 5 to 600. i
would like a program that checks each row such that if
the value in column b is greater than column c, it
deletes the values in that row (or deletes the row
entirely)

ill give you a better challenge next time, i swear...
.
Try this

Sub TestVals()
Dim rng As Range
Dim c As Variant
Set rng = Range(Cells(5, 2), Cells(500, 2))
For Each c In rng
If c > c.Offset(0, 1) Then
c.EntireRow.Delete
End If
Next c
End Sub

Regards
Peter
 

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

Back
Top