Cut out rows based on wildcard criteria

amitcohen

Board Regular
Joined
Jan 14, 2010
Messages
118
Hi

This code loop through list of criteria and move(cut) any row with a match.

How can I use a 'wild card' here?

Code:
    Dim TheRange As Range
    Dim TheCell As Range
    Set TheRange = Range("A1:E3500", Range("A65536").End(xlUp))
    Dim R      As Long
    
    
'Start check list by criteria
For i = 1 To 5 Step 1

    For Each TheCell In TheRange.Cells
     If TheCell = Sheets("Criteria").Range("A" & i).Value Then
                    R = TheCell.Row
            Range(Cells(R, 1), Cells(R, 5)).Cut _
Destination:=Sheets("RemovedData").Range("A65536").End(xlUp).Offset(1, 0)
        End If
    Next TheCell

Next i


Thanks for the help,

Amit.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Maybe like this

Code:
If TheCell.Value Like "*" & Sheets("Criteria").Range("A" & i).Value & "*" Then
 
Upvote 0
Thanks VoG
This is great!! :)

If I may ask one more Q here..
(Or should I start new thread)

How to re-run the macro so it will check the criteria again, this time on column B ?


Amit
 
Upvote 0
Try

Code:
If TheCell.Value Like "*" & Sheets("Criteria").Range("A" & i).Value & "*" _
    Or TheCell.Value Like "*" & Sheets("Criteria").Range("B" & i).Value & "*" Then
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,792
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