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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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
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,214,429
Messages
6,119,424
Members
448,896
Latest member
MadMarty

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