Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Me Me is offline
external usenet poster
 
Posts: 67
Default delete rows when finding certain content.

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..
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default delete rows when finding certain content.

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..

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default delete rows when finding certain content.

On 24 Nov., 04:46, 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..


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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default delete rows when finding certain content.

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
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
Delete rows by content Raza Excel Worksheet Functions 3 November 19th 05 09:20 PM
Hide/Delete entire rows based in the content of one cell Clueless Excel Discussion (Misc queries) 2 October 3rd 05 02:40 PM
Delete Rows on cell content? fpd833 Excel Programming 4 February 10th 05 07:13 PM
Delete Rows Based On Content halem2[_39_] Excel Programming 0 October 12th 04 03:27 PM
Delete Rows Based On Content halem2[_38_] Excel Programming 1 October 12th 04 03:16 PM


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