ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   find text and delete rows. (https://www.excelbanter.com/excel-discussion-misc-queries/169227-find-text-delete-rows.html)

John

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.


CLR

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.


John

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.


CLR

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.


John

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.


dksaluki

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




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com