delete rows with specific text amend current code to pick up upper or lower case

matklt

New Member
Joined
Oct 14, 2016
Messages
5
I have the following code that basically searches column O and deletes any rows that contain the words in the array. Only problem is it wont remove rows where the words have capitals in or vice versa. I have lots of keywords to search for so adding different versions of each word isn't an option

Code:
Sub DelRows()
Dim V As Variant, DeleteMe As Variant
DeleteMe = Array("suma", "screw")
For Each V In DeleteMe
 Columns("O").Replace "*" & V & "*", "#N/A", xlWhole, , True, False, False
Next
On Error Resume Next
 Columns("O").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
On Error GoTo 0

End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This isn't a full solution, but it may steer you in the right direction. Using "UCase" you can convert everything in a string to upper case, then do the replace task. This code converts everything in your array to uppercase, so works on text in the "O" column which is ALL upper case, but so far I can't see how to get the col O values to upper case, so it's still not working on anything in col O which is only PARTLY upper case...
Code:
Sub DelRows()
Dim V As Variant, DeleteMe As Variant
Dim cl As Range
Dim rng As Range

Set rng = ActiveSheet.Columns("O")
DeleteMe = Array("suma", "screw")

For Each V In DeleteMe
 Columns("O").Replace "*" & UCase(V) & "*", "#N/A", xlWhole, , True, False, False

Next
On Error Resume Next
 Columns("O").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
On Error GoTo 0

End Sub
 
Upvote 0
Try
Code:
 Columns("O").Replace "*" & V & "*", "#N/A", xlWhole, , [COLOR=#ff0000]False, ,[/COLOR] False, False
You had match case set to True, rather than False.
You where also missing an extra coma.
 
Last edited:
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,793
Members
449,048
Latest member
greyangel23

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