Deleting rows based on certain text/data in a column

excelisnotmyforte

New Member
Joined
Apr 3, 2019
Messages
7
Hi gurus,

I would like to delete rows that contain the text "Off" in column C (under SSG). Is there a way to do this without macros?

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Time[/TD]
[TD]Engine[/TD]
[TD]SSG[/TD]
[TD]Hatch[/TD]
[TD]RPM[/TD]
[/TR]
[TR]
[TD]0700[/TD]
[TD]Off[/TD]
[TD]On[/TD]
[TD]Open[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]0800[/TD]
[TD]On[/TD]
[TD]Off[/TD]
[TD]Open[/TD]
[TD]1200[/TD]
[/TR]
[TR]
[TD]0900[/TD]
[TD]On[/TD]
[TD]On[/TD]
[TD]Closed[/TD]
[TD]1600[/TD]
[/TR]
[TR]
[TD]1000[/TD]
[TD]On[/TD]
[TD]On[/TD]
[TD]Closed [/TD]
[TD]1600[/TD]
[/TR]
[TR]
[TD]1100[/TD]
[TD]On[/TD]
[TD]Off[/TD]
[TD]Closed[/TD]
[TD]1200[/TD]
[/TR]
</tbody>[/TABLE]

Thank you in advanced!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Helo, untested but straight forward.

Test on a COPY of your data as this deletes information

Code:
Sub DeleteRows()
    Dim fr As Long, lr As Long, l As Long ' first row, last row, counter
    
    'first row no.
    fr = 2 'change as necessary
    
    'last row no.
    lr = Range("C" & Rows.Count).End(xlUp).Row
    
    'loop up as we are deleteing
    For l = lr To fr Step -1
        If Trim(Range("C" & l)) = "Off" Then Rows(l).Delete
    Next l
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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