Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Find row and delete following rows

I want to search for a value in a cell and delete the row that contains it
and all others below it. I am struggling with how to define that as a range.
Suggestions?
--
Teach me to fish! Thanks for the help.
Pax, M
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Find row and delete following rows

Sub TryNow()
Dim myC As Range
Set myC = Cells.Find("What you are looking for")
If myC Is Nothing Then
MsgBox "That wasn't found"
Else
Range(myC, myC.End(xlDown)).EntireRow.Delete
End If
End Sub

If you are looking for a number, don't use the quotes.

HTH,
Bernie
MS Excel MVP


"m stroup" wrote in message
...
I want to search for a value in a cell and delete the row that contains it
and all others below it. I am struggling with how to define that as a range.
Suggestions?
--
Teach me to fish! Thanks for the help.
Pax, M



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Find row and delete following rows

this is what i came up with - i assumed your value was a string - you
could change that.........
'===================
Option Explicit

Sub delete_row_and_below()

Dim rFound As Range
Dim myRange As Range
Dim myLastRow As Long
Dim sName As String

myLastRow = ActiveSheet.Cells(10000, 1).End(xlUp).Row
Set myRange = ActiveSheet.Range("a1:a" & myLastRow)
sName = "Paul"

Set rFound = myRange.Find(What:=sName, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)

If rFound Is Nothing Then
MsgBox sName & " was not found in Range."
Else
Set myRange = ActiveSheet.Range("a" & rFound.Row _
& ":f" & myLastRow)
myRange.EntireRow.Delete
End If

End Sub
'========================
hope it gives you a place to start!
:)
susan



On Nov 7, 11:35*am, m stroup
wrote:
I want to search for a value in a cell and delete the row that contains it
and all others below it. *I am struggling with how to define that as a range.
Suggestions?
--
Teach me to fish! *Thanks for the help.
Pax, M


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Find row and delete following rows

Thank you both for your quick response. I tweaked it a little and it is
working beautifully.
--
Teach me to fish! Thanks for the help.
Pax, M


"m stroup" wrote:

I want to search for a value in a cell and delete the row that contains it
and all others below it. I am struggling with how to define that as a range.
Suggestions?
--
Teach me to fish! Thanks for the help.
Pax, M

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
find text and delete rows. John Excel Discussion (Misc queries) 5 December 12th 07 04:25 AM
Find and delete all other rows Murray Excel Discussion (Misc queries) 1 August 7th 07 02:54 AM
Macro to find and delete rows! Heather O'Malley Excel Discussion (Misc queries) 2 April 12th 06 01:53 PM
Find & Delete Rows Steve Wallis Excel Programming 2 June 17th 05 07:06 AM
find and delete rows sulie[_2_] Excel Programming 2 June 7th 05 09:47 AM


All times are GMT +1. The time now is 10:51 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"