ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear contents if x is not in the row (https://www.excelbanter.com/excel-programming/312570-clear-contents-if-x-not-row.html)

Mighvik

Clear contents if x is not in the row
 
I need to clear the contents in all rows except rows with
the word "ALL" in it.

Can someone help?
Thanks



Tom Ogilvy

Clear contents if x is not in the row
 
Sub Tester9()
Dim rng As Range
Dim fAddr As String
Columns(1).Insert
Set rng = Cells.Find("All", AFter:=Range("IV65535"), _
LookIn:=xlValues, LookAt:=xlPart)
If Not rng Is Nothing Then
fAddr = rng.Address
Do
Cells(rng.Row, 1).Value = "X"
Set rng = Cells.FindNext(rng)
Loop While rng.Address < fAddr
Else
ActiveSheet.UsedRange.Rows.Delete
Columns(1).Delete
Exit Sub
End If
Set rng = Columns(1).SpecialCells(xlBlanks)
rng.EntireRow.Delete
Columns(1).Delete
End Sub

--
Regards,
Tom Ogilvy

"Mighvik" wrote in message
...
I need to clear the contents in all rows except rows with
the word "ALL" in it.

Can someone help?
Thanks






All times are GMT +1. The time now is 09:57 AM.

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