ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete rows that don't contain '+' or '++' (https://www.excelbanter.com/excel-programming/300946-delete-rows-dont-contain.html)

esexcel

Delete rows that don't contain '+' or '++'
 
My excel file has multiple rows and columns.
I need to delete all the rows that don't have at least
one cell with "+" or "++"
I would appreciate any sample VB code

Thank yo

--
Message posted from http://www.ExcelForum.com


Ron de Bruin

Delete rows that don't contain '+' or '++'
 
Hi esexcel

Try this one for row 1 -100

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 = 1
EndRow = 100
For Lrow = EndRow To StartRow Step -1
If Application.WorksheetFunction.CountIf(.Rows(Lrow), "*+*") = 0 _
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


"esexcel " wrote in message ...
My excel file has multiple rows and columns.
I need to delete all the rows that don't have at least
one cell with "+" or "++"
I would appreciate any sample VB code

Thank you


---
Message posted from http://www.ExcelForum.com/




esexcel[_2_]

Delete rows that don't contain '+' or '++'
 
Thanks Ron

It worked!

However, I need only to display these values "+" "++" and "+++"
The way that the code is it also displays "+-"
What should I do?

Thanks agai

--
Message posted from http://www.ExcelForum.com


esexcel[_3_]

Delete rows that don't contain '+' or '++'
 
Hi Ron

Nevermind. I replaced the +- values with something else, that way I ca
run the script without modifying it

Thank

--
Message posted from http://www.ExcelForum.com


Ron de Bruin

Delete rows that don't contain '+' or '++'
 
Thanks for your feedback
I don't have to make a example for you then

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


"esexcel " wrote in message ...
Hi Ron

Nevermind. I replaced the +- values with something else, that way I can
run the script without modifying it

Thanks


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 11:14 AM.

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