Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Getting rid of "extraneous" data (rows)

Option Explicit
Sub Test1()
Dim varr As Variant
Dim rng As Range
Dim rng1 As Range
Dim cell As Range
Dim i As Long
Dim bMatch As Boolean
Dim fAddr As String
varr = Array("Card Care", _
"High End Ordering", _
"Indianapolis", _
"Kansas City", _
"Mesa", _
"Minneapolis", _
"New Orleans", _
"Pittsburgh", _
"Syracuse")
Set rng = Range(Cells(2, "S"), _
Cells(Rows.Count, "S").End(xlUp))
For Each cell In rng
bMatch = False
For i = LBound(varr) To UBound(varr)
If LCase(cell) = LCase(varr(i)) Then
bMatch = True
Exit For
End If
Next
If Not bMatch Then
If rng1 Is Nothing Then
Set rng1 = cell
Else
Set rng1 = Union(rng1, cell)
End If
End If
Next
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If

Set rng1 = Nothing
Set rng = Columns(6).Find("UMIU")
If Not rng Is Nothing Then
fAddr = rng.Address
Do
If LCase(Cells(rng.Row, "S")) = "card care" Then
If rng1 Is Nothing Then
Set rng1 = rng
Else
Set rng1 = Union(rng, rng1)
End If
End If
Set rng = Columns(6).FindNext(rng)
Loop While Not rng Is Nothing And rng.Address < fAddr

If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
End If
End Sub

Test this on a copy of your data

--
Regards,
Tom Ogilvy


"JLZ" wrote in message
...
Hello everyone,

I've got an excel file that contains many entries I don't need. I'd like

to either keep just certain rows of information and/or delete other rows. I
currently have columns "A" through "U" with information. I'd like to retain
only the rows that have certain entries in column "S".

For example, currently column "S" contains the city or office name. I'd

like to keep only the rows for the following:

"Card Care"
"High End Ordering"
"Indianapolis"
"Kansas City"
"Mesa"
"Minneapolis"
"New Orleans"
"Pittsburgh"
"Syracuse"

Also, but not as important, I'd like to get rid of certain rows for the

"Card Care" office. I'd like to get rid of the "UMIU" classification. This
classification is in column "F".

Any ideas how I might be able to accomplish this? I would very much

appreciate any help I could get.



Reply
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 10:10 AM.

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"