Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,069
Default find text and delete rows.

need a macro, anyone know how to find a text in the worksheet and delete
range rows from the text it fund. sample: text in column A row 12, I want to
delete rows from rows 3-12 or text in rows 50, I want to delete from rows
50-58. pls help.

  #2   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default find text and delete rows.

You would have to define your exact conditions, including what the TEXT is,
or where it may be found, and which rows relative to it's found location to
be deleted. Then a macro can be written to satisfy your requirements.

Vaya con Dios,
Chuck, CABGx3


"John" wrote:

need a macro, anyone know how to find a text in the worksheet and delete
range rows from the text it fund. sample: text in column A row 12, I want to
delete rows from rows 3-12 or text in rows 50, I want to delete from rows
50-58. pls help.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,069
Default find text and delete rows.

the text is HEADER in rows 12, so I want to del start from rows 12-rows 1.
and in rows 50 text is MONEY, I want to del rows from 50-58. if the text in
every worksheet at the different rows can it use same macro.

"CLR" wrote:

You would have to define your exact conditions, including what the TEXT is,
or where it may be found, and which rows relative to it's found location to
be deleted. Then a macro can be written to satisfy your requirements.

Vaya con Dios,
Chuck, CABGx3


"John" wrote:

need a macro, anyone know how to find a text in the worksheet and delete
range rows from the text it fund. sample: text in column A row 12, I want to
delete rows from rows 3-12 or text in rows 50, I want to delete from rows
50-58. pls help.

  #4   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default find text and delete rows.

Maybe this will help..........it will perform on every sheet in the workbook.
Just be sure to back up your data first and use only a copy for testing.

Sub DeleteCertainRows()
Dim sh As Worksheet
For Each sh In Worksheets
sh.Select
If Range("a50").Value = "money" Then
Rows("50:58").EntireRow.Delete
Else
End If

If Range("a12").Value = "header" Then
Rows("1:12").EntireRow.Delete
Else
End If
Next sh
End Sub


Vaya con Dios,
Chuck, CABGx3



"John" wrote:

the text is HEADER in rows 12, so I want to del start from rows 12-rows 1.
and in rows 50 text is MONEY, I want to del rows from 50-58. if the text in
every worksheet at the different rows can it use same macro.

"CLR" wrote:

You would have to define your exact conditions, including what the TEXT is,
or where it may be found, and which rows relative to it's found location to
be deleted. Then a macro can be written to satisfy your requirements.

Vaya con Dios,
Chuck, CABGx3


"John" wrote:

need a macro, anyone know how to find a text in the worksheet and delete
range rows from the text it fund. sample: text in column A row 12, I want to
delete rows from rows 3-12 or text in rows 50, I want to delete from rows
50-58. pls help.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,069
Default find text and delete rows.

Hi, this only can help for this worksheet. like what I said in every
worksheet the "header" and "money" is in different rows. that I need is a
macro to do (find "header" in the worksheet and del from that rows up to the
first rows and find the "money" then del from that rows to the last rows. so
I only need to keep the rows under"header" to the rows befor "money". is that
clear.

"CLR" wrote:

Maybe this will help..........it will perform on every sheet in the workbook.
Just be sure to back up your data first and use only a copy for testing.

Sub DeleteCertainRows()
Dim sh As Worksheet
For Each sh In Worksheets
sh.Select
If Range("a50").Value = "money" Then
Rows("50:58").EntireRow.Delete
Else
End If

If Range("a12").Value = "header" Then
Rows("1:12").EntireRow.Delete
Else
End If
Next sh
End Sub


Vaya con Dios,
Chuck, CABGx3



"John" wrote:

the text is HEADER in rows 12, so I want to del start from rows 12-rows 1.
and in rows 50 text is MONEY, I want to del rows from 50-58. if the text in
every worksheet at the different rows can it use same macro.

"CLR" wrote:

You would have to define your exact conditions, including what the TEXT is,
or where it may be found, and which rows relative to it's found location to
be deleted. Then a macro can be written to satisfy your requirements.

Vaya con Dios,
Chuck, CABGx3


"John" wrote:

need a macro, anyone know how to find a text in the worksheet and delete
range rows from the text it fund. sample: text in column A row 12, I want to
delete rows from rows 3-12 or text in rows 50, I want to delete from rows
50-58. pls help.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default find text and delete rows.

Assuming you found "money" and/or "header", do you want to delete the
same amount of rows each time? If so, you could do create 2 ranges:
one for HEADER and one for MONEY. then offset them and delete the
rows accordingly. Maybe something like this?

Dim rngMoney As Range
Dim srchMoney As Range

Set srchMoney = Cells.Find("money")
If Not srchMoney Is Nothing Then
Set rngMoney = Range(srchMoney, srchMoney.Offset(0, -9))
End If


and do the same for "header".....


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 and delete all other rows Murray Excel Discussion (Misc queries) 1 August 7th 07 02:54 AM
Find & delete rows with ID's from another sheet. plys Excel Discussion (Misc queries) 1 December 21st 06 04:21 PM
how do i find and delete all empty rows in an excel worksheet AinSF Excel Worksheet Functions 3 September 1st 06 01:38 AM
Macro to find and delete rows! Heather O'Malley Excel Discussion (Misc queries) 2 April 12th 06 01:53 PM
How do I find duplicate rows in a list in Excel, and not delete it Matthew in FL Excel Discussion (Misc queries) 2 June 15th 05 09:11 PM


All times are GMT +1. The time now is 01:56 AM.

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"