LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Deleting Rows

Hi KJ,

Try:

Sub DelRows()
Dim delRange As Range
Dim rCell As Range
Dim vArr As Variant
Dim blDelete As Boolean

vArr = Array(428, 491, 492, 493, 495, 496)

With ActiveSheet
For Each rCell In Intersect(.UsedRange, .Columns(7))
blDelete = False
On Error Resume Next
blDelete = Application.Match(rCell.Value, vArr, 0)
On Error GoTo 0
If blDelete Then
If Not delRange Is Nothing Then
Set delRange = Union(delRange, rCell.EntireRow)
Else
Set delRange = rCell.EntireRow
End If
End If
Next rCell
End With
If Not delRange Is Nothing Then
delRange.Delete
Else
MsgBox "No rows deleted"
End If
End Sub

---
Regards,
Norman



"KJ Dahl" wrote in message
...
Hi everyone,
I seem to be stuck again with a problem that probably is very easy.
The data in my sheet is spread over 7 Columns and about 200-300 Rows.
I want to loop through column 7 and delete the entire row if the value is
different to 6 possible values.
So if the value in column 7 is different from for example 428, 491, 492,
493, 495 and 496 then the entire row should be deleted.
I have tried putting these values in an array and do a comparison. That
didn't work out.
Neither did a comparison with 5 OR's.

Hope this is understandable, please let me know if you want to see the
code I've used.

Thanks for your help

KJ






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Excel Worksheet Functions 1 November 12th 08 01:39 PM
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
deleting hidden rows so i can print only the rows showing?????? jenn Excel Worksheet Functions 0 October 6th 05 04:05 PM


All times are GMT +1. The time now is 05:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"