Delete selected row, and all rows below *solved*

thorpyuk

Well-known Member
Joined
Mar 14, 2006
Messages
1,453
Hiya,

I have the following code, to find the 1st cell in column CG that contains a value of more than -200. I wish to delete the entire row that this resides on, and all rows below. Please can anyone help? Thanks!

Code:
Range("CG2").Select
    Do While Not Selection.Value > -200
        Selection.Offset(1, 0).Select
    Loop
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Try this:
Code:
Sub DeleteMe()
Dim c As Long
Dim Limit As Long
Limit = Cells(Rows.Count, 85).End(xlUp).Row
For c = 1 To Limit
    If Cells(c, 85) > -200 Then
        Rows(c & ":" & Limit).Delete shift:=xlUp
        Exit Sub
    End If
Next c
End Sub
 
Upvote 0

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,941
Maybe modify to this:

Code:
Sub DeleteMe() 
Dim c As Long 
Dim Limit As Long 
Limit = Cells(Rows.Count, 85).End(xlUp).Row 
For c = 2 To Limit 
    If Cells(c, 85).Value > -200 Then 
        Rows(c & ":" & Limit).Delete shift:=xlUp 
        Exit Sub 
    End If 
Next c 
End Sub

I modified Lewiy's code to start at row 2 and look at the value in cell CG2 and down
 
Upvote 0

Forum statistics

Threads
1,191,307
Messages
5,985,898
Members
439,986
Latest member
DaveTee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top