Help With Macro!

Raconteur

New Member
Joined
Sep 3, 2008
Messages
5
Hi,

I'd be indebted to anyone who can help me with some Macro problems i'm having.

I have a Macro, which works perfectly, for deleting any row where a cell in the active column does not contain a value:

Sub del_1()
Do While Not IsEmpty(ActiveCell)
If Not ActiveCell.Value Like "*MrExcel*" THEN
ActiveCell.EntireRow.Delete shift = xlDown
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub

What I am now trying to do, is modify it, so that i can run a macro which deletes all rows where the cell in the active column does not contain a number of different values, not just the single value.

For example, i'd like to delete all rows without 'MrExcel', or 'Macro', or 'Forum' in the cells in the active column.

Any help would be massively appreciated.

Many thanks,

D.
 

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.
Try This. Select any cell in specific column.Run code.
Code:
Dim Last, Dn As Integer, oLt, oRt, Col As String
Col = Split(Selection.Address, "$")(1)

Last = Range(Col & Rows.Count).End(xlUp).Row
For Dn = Last To 1 Step -1
Select Case Cells(Dn, Col)
Case Is = "Mr Excell"
Case Is = "Macro"
Case Is = "Forum"
Case Else
Rows(Dn).EntireRow.Delete shift:=xlDown
End Select
Next Dn
Regards Mick
 
Upvote 0
Mick, that worked a treat, thank you ever so much.

Just to note, i had to break up my data into 4 parts, as it was 65k rows, and the Macro wouldn't allow me to run it on anything over about 20k.

Many many thanks.
 
Upvote 0
Hi, I dont' know the answer to that.
Do you actually want to delete the rows, or just put all the "Select case" items in a list one below the other.??
With 65K rows it's going to take some while !
Mick
 
Upvote 0
Delete the rows i don't need, to leave behind the ones i do.

It only took me about 5 mins to chop it up, and run your Macro, that's a lot quicker than any other method i know.
 
Upvote 0

Forum statistics

Threads
1,214,406
Messages
6,119,330
Members
448,888
Latest member
Arle8907

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