PC Review


Reply
Thread Tools Rate Thread

delete rows when finding certain content.

 
 
me
Guest
Posts: n/a
 
      24th Nov 2007
In a data containing worksheet, in column "A"
I would like to write a macro which finds the cell with content
"text2delete" and delete all the rows below including this "text2delete" row.


Something like below. Any help will be appreciated greatly. Thanks

Sub content_del()
$A = Find "text2delete" entered value at A1 column
then

Range(A$:A65000").Select
Selection.EntireRow.Delete
End Sub


or if it is easier this way,

delete all the rows A column value as "text2delete"

I guess this code should work for me.

Any help is greatly appreciated. Thanks..
 
Reply With Quote
 
 
 
 
sebastienm
Guest
Posts: n/a
 
      24th Nov 2007
Hi,
try something like:

dim rg as range
''' find the cell
set rg= activesheet.range("a:a").Find
(what:=<your_text>,lookin:=xlValues,...)
''' delete the rows bellow including rg
if not rg is nothing then
set rg=range(rg,rg.parent.cells(65536,1))
rg.entirerow.delete
end if
--
Regards,
Sébastien
<http://www.ondemandanalysis.com>


"me" wrote:

> In a data containing worksheet, in column "A"
> I would like to write a macro which finds the cell with content
> "text2delete" and delete all the rows below including this "text2delete" row.
>
>
> Something like below. Any help will be appreciated greatly. Thanks
>
> Sub content_del()
> $A = Find "text2delete" entered value at A1 column
> then
>
> Range(A$:A65000").Select
> Selection.EntireRow.Delete
> End Sub
>
>
> or if it is easier this way,
>
> delete all the rows A column value as "text2delete"
>
> I guess this code should work for me.
>
> Any help is greatly appreciated. Thanks..

 
Reply With Quote
 
Per Jessen
Guest
Posts: n/a
 
      24th Nov 2007
On 24 Nov., 04:46, me <m...@discussions.microsoft.com> wrote:
> In a data containing worksheet, in column "A"
> I would like to write a macro which finds the cell with content
> "text2delete" and delete all the rows below including this "text2delete" row.
>
> Something like below. Any help will be appreciated greatly. Thanks
>
> Sub content_del()
> $A = Find "text2delete" entered value at A1 column
> then
>
> Range(A$:A65000").Select
> Selection.EntireRow.Delete
> End Sub
>
> or if it is easier this way,
>
> delete all the rows A column value as "text2delete"
>
> I guess this code should work for me.
>
> Any help is greatly appreciated. Thanks..


Try this:

Sub DeleteText()
LookFor = "text2delete"

Range("A1").EntireColumn.Select
Selection.Find(What:=LookFor, After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Select

Regards,

Per

FirstCell = Selection.Address
LastCell = Range(FirstCell).End(xlDown).Address
Range(FirstCell, LastCell).Delete

End Sub
 
Reply With Quote
 
thefirstcybot
Guest
Posts: n/a
 
      24th Nov 2007
Try going to www.learningiseasy.co.uk and look at the marco page and you will
find a marco to do this and maybe some more stuff. I started creating this
website but due to the lack of visitors I have not updated it for ages.

Hope this helps

"me" wrote:

> In a data containing worksheet, in column "A"
> I would like to write a macro which finds the cell with content
> "text2delete" and delete all the rows below including this "text2delete" row.
>
>
> Something like below. Any help will be appreciated greatly. Thanks
>
> Sub content_del()
> $A = Find "text2delete" entered value at A1 column
> then
>
> Range(A$:A65000").Select
> Selection.EntireRow.Delete
> End Sub
>
>
> or if it is easier this way,
>
> delete all the rows A column value as "text2delete"
>
> I guess this code should work for me.
>
> Any help is greatly appreciated. Thanks..

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete rows by content =?Utf-8?B?UmF6YQ==?= Microsoft Excel Worksheet Functions 3 19th Nov 2005 09:20 PM
Delete Rows on cell content? =?Utf-8?B?ZnBkODMz?= Microsoft Excel Programming 7 10th Feb 2005 08:54 PM
Delete Rows Based On Content halem2 Microsoft Excel Programming 0 12th Oct 2004 03:27 PM
Delete Rows Based On Content halem2 Microsoft Excel Programming 1 12th Oct 2004 03:16 PM
How do I delete rows based upon the content (without sorting the . =?Utf-8?B?Y2V2?= Microsoft Excel Misc 8 1st Oct 2004 02:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:11 PM.