ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Easy one (https://www.excelbanter.com/excel-programming/294580-easy-one.html)

Lawson

Easy one
 
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...

Ron de Bruin

Easy one
 
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


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Lawson" wrote in 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...




Peter Atherton[_3_]

Easy one
 

-----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


All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com