Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
find text and delete rows. | Excel Discussion (Misc queries) | |||
Find and delete all other rows | Excel Discussion (Misc queries) | |||
Macro to find and delete rows! | Excel Discussion (Misc queries) | |||
Find & Delete Rows | Excel Programming | |||
find and delete rows | Excel Programming |