Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I delete some rows while keeping others

Every day I receive a list like the following:

9 - spice

7 - aurora

5 - dallas

4 - tulsa

4 - frank

4 - eville

3 - waco

3 - pont

2 - warren

2 - ripon

2 - quincy

2 - lakep

2 - gulf

2 - gretna

2 - george

2 - birm

1 - wmemph

1 - winch

1 - wfalls

1 - sulliv

1 - sioux



This list includes many entries that don't concern me, but a few of them do.
The numbers preceding the "- text" change every day, but the text does not
change. I would like to be able to delete the rows that don't concern me,
how would I go about doing this?



Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default How do I delete some rows while keeping others

There's a few ways to approach this, but a simple one would go
something like:

Public Sub DeleteRows()
Range("A1").Select

Do Until ActiveCell.Value = Empty
If ActiveCell.Value = "Value I don't want" Then
ActiveCell.EntireRow.Delete shift:=xlUp
ElseIf ActiveCell.Value = "Another value I dont want" Then
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub


Daryl Timm wrote:
Every day I receive a list like the following:

9 - spice

7 - aurora

5 - dallas

4 - tulsa

4 - frank

4 - eville

3 - waco

3 - pont

2 - warren

2 - ripon

2 - quincy

2 - lakep

2 - gulf

2 - gretna

2 - george

2 - birm

1 - wmemph

1 - winch

1 - wfalls

1 - sulliv

1 - sioux



This list includes many entries that don't concern me, but a few of them do.
The numbers preceding the "- text" change every day, but the text does not
change. I would like to be able to delete the rows that don't concern me,
how would I go about doing this?



Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default How do I delete some rows while keeping others

First off we need to know what concerns you. After that the problem is just
one of mechanics. Do you wnat to keep certain numbers, or certain cities or
some combination there of???
--
HTH...

Jim Thomlinson


"Daryl Timm" wrote:

Every day I receive a list like the following:

9 - spice

7 - aurora

5 - dallas

4 - tulsa

4 - frank

4 - eville

3 - waco

3 - pont

2 - warren

2 - ripon

2 - quincy

2 - lakep

2 - gulf

2 - gretna

2 - george

2 - birm

1 - wmemph

1 - winch

1 - wfalls

1 - sulliv

1 - sioux



This list includes many entries that don't concern me, but a few of them do.
The numbers preceding the "- text" change every day, but the text does not
change. I would like to be able to delete the rows that don't concern me,
how would I go about doing this?



Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default How do I delete some rows while keeping others

My mistake, I missed one line of code in that example. It should be as
follows:

Public Sub DeleteRows()
Range("A1").Select


Do Until ActiveCell.Value = Empty
If ActiveCell.Value = "Value I don't want" Then
ActiveCell.EntireRow.Delete shift:=xlUp
ElseIf ActiveCell.Value = "Another value I dont want" Then
ActiveCell.EntireRow.Delete shift:=xlUp
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub


Jim Thomlinson wrote:
First off we need to know what concerns you. After that the problem is just
one of mechanics. Do you wnat to keep certain numbers, or certain cities or
some combination there of???
--
HTH...

Jim Thomlinson


"Daryl Timm" wrote:

Every day I receive a list like the following:

9 - spice

7 - aurora

5 - dallas

4 - tulsa

4 - frank

4 - eville

3 - waco

3 - pont

2 - warren

2 - ripon

2 - quincy

2 - lakep

2 - gulf

2 - gretna

2 - george

2 - birm

1 - wmemph

1 - winch

1 - wfalls

1 - sulliv

1 - sioux



This list includes many entries that don't concern me, but a few of them do.
The numbers preceding the "- text" change every day, but the text does not
change. I would like to be able to delete the rows that don't concern me,
how would I go about doing this?



Thanks!




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I delete some rows while keeping others

I want to delete the row where the city does not concern me.


"Jim Thomlinson" wrote in message
...
First off we need to know what concerns you. After that the problem is
just
one of mechanics. Do you wnat to keep certain numbers, or certain cities
or
some combination there of???
--
HTH...

Jim Thomlinson


"Daryl Timm" wrote:

Every day I receive a list like the following:

9 - spice

7 - aurora

5 - dallas

4 - tulsa

4 - frank

4 - eville

3 - waco

3 - pont

2 - warren

2 - ripon

2 - quincy

2 - lakep

2 - gulf

2 - gretna

2 - george

2 - birm

1 - wmemph

1 - winch

1 - wfalls

1 - sulliv

1 - sioux



This list includes many entries that don't concern me, but a few of them
do.
The numbers preceding the "- text" change every day, but the text does
not
change. I would like to be able to delete the rows that don't concern
me,
how would I go about doing this?



Thanks!







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default How do I delete some rows while keeping others

Give this a try... You will need to define which sheet you want to delete the
rows from (Sheet1 in my example) and the cities. I am deleting dallas and
tulsa...

Public Sub DeleteCities()
Call DeleteCity("dallas")
Call DeleteCity("tulsa")
End Sub

Sub DeleteCity(ByVal City As String)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String

Set wks = Sheets("Sheet1") 'Change This
Set rngToSearch = wks.Range("A:A") 'Possibly Change this
Set rngFound = rngToSearch.Find(What:=City, _
Lookat:=xlPart, _
LookIn:=xlValues, _
MatchCase:=False)
If Not rngFound Is Nothing Then
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.EntireRow.Delete
End If
End Sub
--
HTH...

Jim Thomlinson


"Daryl Timm" wrote:

I want to delete the row where the city does not concern me.


"Jim Thomlinson" wrote in message
...
First off we need to know what concerns you. After that the problem is
just
one of mechanics. Do you wnat to keep certain numbers, or certain cities
or
some combination there of???
--
HTH...

Jim Thomlinson


"Daryl Timm" wrote:

Every day I receive a list like the following:

9 - spice

7 - aurora

5 - dallas

4 - tulsa

4 - frank

4 - eville

3 - waco

3 - pont

2 - warren

2 - ripon

2 - quincy

2 - lakep

2 - gulf

2 - gretna

2 - george

2 - birm

1 - wmemph

1 - winch

1 - wfalls

1 - sulliv

1 - sioux



This list includes many entries that don't concern me, but a few of them
do.
The numbers preceding the "- text" change every day, but the text does
not
change. I would like to be able to delete the rows that don't concern
me,
how would I go about doing this?



Thanks!






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I delete some rows while keeping others

Works like a dream!!!

Thanks Jim


"Jim Thomlinson" wrote in message
...
Give this a try... You will need to define which sheet you want to delete
the
rows from (Sheet1 in my example) and the cities. I am deleting dallas and
tulsa...

Public Sub DeleteCities()
Call DeleteCity("dallas")
Call DeleteCity("tulsa")
End Sub

Sub DeleteCity(ByVal City As String)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String

Set wks = Sheets("Sheet1") 'Change This
Set rngToSearch = wks.Range("A:A") 'Possibly Change this
Set rngFound = rngToSearch.Find(What:=City, _
Lookat:=xlPart, _
LookIn:=xlValues, _
MatchCase:=False)
If Not rngFound Is Nothing Then
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.EntireRow.Delete
End If
End Sub
--
HTH...

Jim Thomlinson


"Daryl Timm" wrote:

I want to delete the row where the city does not concern me.


"Jim Thomlinson" wrote in
message
...
First off we need to know what concerns you. After that the problem is
just
one of mechanics. Do you wnat to keep certain numbers, or certain
cities
or
some combination there of???
--
HTH...

Jim Thomlinson


"Daryl Timm" wrote:

Every day I receive a list like the following:

9 - spice

7 - aurora

5 - dallas

4 - tulsa

4 - frank

4 - eville

3 - waco

3 - pont

2 - warren

2 - ripon

2 - quincy

2 - lakep

2 - gulf

2 - gretna

2 - george

2 - birm

1 - wmemph

1 - winch

1 - wfalls

1 - sulliv

1 - sioux



This list includes many entries that don't concern me, but a few of
them
do.
The numbers preceding the "- text" change every day, but the text does
not
change. I would like to be able to delete the rows that don't concern
me,
how would I go about doing this?



Thanks!








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
How to delete all duplicate records - without keeping one of them Aviva B Excel Worksheet Functions 5 December 8th 09 02:59 PM
Keeping Rows Together KLG Excel Worksheet Functions 1 September 25th 09 09:10 PM
keeping the rows together king_reggie New Users to Excel 10 October 7th 07 04:27 AM
Keeping duplicate rows Daniell Excel Worksheet Functions 2 April 18th 05 06:56 AM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 08:20 PM.

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

About Us

"It's about Microsoft Excel"