PC Review


Reply
Thread Tools Rate Thread

delete rows with multiple criteria

 
 
=?Utf-8?B?c3ZlcnJl?=
Guest
Posts: n/a
 
      24th Nov 2006
Hi

I would like to delete all rows that contain these names in col C

EXO_BASKET
EXO_CLI
EXO_EXOTIX
EXO_FLOW
FXSECUR
EXO_OTC_CLI
EXO_OTC_EXOTIX
EXO_OTC_FLOW
EXO_TURBO
EXO_OTC_BASKET

How do I write this code?

Many thanks for the help

Br
Sverre
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      24th Nov 2006
you can use a for/next loop

if cells(i,"c")="a" or cells(i,"c")="b" then rows(i).delete

or a select case statement
case is "a", "b", "c"

--
Don Guillett
SalesAid Software
(E-Mail Removed)
"sverre" <(E-Mail Removed)> wrote in message
news:A5E1B315-9762-4738-8C42-(E-Mail Removed)...
> Hi
>
> I would like to delete all rows that contain these names in col C
>
> EXO_BASKET
> EXO_CLI
> EXO_EXOTIX
> EXO_FLOW
> FXSECUR
> EXO_OTC_CLI
> EXO_OTC_EXOTIX
> EXO_OTC_FLOW
> EXO_TURBO
> EXO_OTC_BASKET
>
> How do I write this code?
>
> Many thanks for the help
>
> Br
> Sverre



 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      26th Nov 2006
Hi Sverre

Another option is to enter the names in another sheet and use Match
I use a sheet named "Sheet2" with in A1:A20 the values you want to delete

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1

With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1

If IsError(.Cells(Lrow, "C").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf Not IsError(Application.Match(.Cells(Lrow, "C").Value, _
Sheets("Sheet2").Range("A1:A20"), 0)) Then .Rows(Lrow).Delete

End If
Next
End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub

More information here
http://www.rondebruin.nl/delete.htm


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


"sverre" <(E-Mail Removed)> wrote in message news:A5E1B315-9762-4738-8C42-(E-Mail Removed)...
> Hi
>
> I would like to delete all rows that contain these names in col C
>
> EXO_BASKET
> EXO_CLI
> EXO_EXOTIX
> EXO_FLOW
> FXSECUR
> EXO_OTC_CLI
> EXO_OTC_EXOTIX
> EXO_OTC_FLOW
> EXO_TURBO
> EXO_OTC_BASKET
>
> How do I write this code?
>
> Many thanks for the help
>
> Br
> Sverre

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete rows based on multiple criteria puiuluipui Microsoft Excel Misc 6 3rd Jul 2009 01:58 PM
Counting characters in multiple rows when rows meet specific criteria news.virginmedia.com Microsoft Excel Worksheet Functions 3 28th Jun 2008 09:03 PM
Delete Rows that fit a certain criteria =?Utf-8?B?anBpdHRhcmk=?= Microsoft Excel Programming 3 2nd Nov 2007 03:22 PM
Delete rows with different criteria =?Utf-8?B?Sm9obg==?= Microsoft Excel Programming 7 13th Jul 2005 05:38 PM
Delete rows w/o criteria RickK Microsoft Excel Programming 2 31st Oct 2003 04:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:12 PM.