ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting rows (https://www.excelbanter.com/excel-programming/292746-deleting-rows.html)

alexm999[_61_]

Deleting rows
 
How do I delete 3 rows after the rows that starts off with the wor
"ADDRESS" ?

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Deleting rows
 
Hi Alex,

Try this

Dim oFound As Range

Set oFound = Cells.Find("ADDRESS")
If Not oFound Is Nothing Then
oFound.Offset(1, 0).Resize(3, 1).EntireRow.Delete
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"alexm999 " wrote in message
...
How do I delete 3 rows after the rows that starts off with the word
"ADDRESS" ??


---
Message posted from http://www.ExcelForum.com/




alexm999[_62_]

Deleting rows
 
How do I loop it, I have the word ADDRESS in my spreadsheet showing u
about 100 times. I'd like to scan through the whole spreadsheet an
delete 3 rows after each word ADDRES

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Deleting rows
 
Why didn't you say?

Dim oFound As Range
Dim firstaddress

Set oFound = Cells.Find("ADDRESS")
If Not oFound Is Nothing Then
firstaddress = oFound.Address
Do
oFound.Offset(1, 0).Resize(3, 1).EntireRow.Delete
Set oFound = Cells.FindNext(oFound)
Loop While Not oFound Is Nothing And firstaddress < oFound.Address
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"alexm999 " wrote in message
...
How do I loop it, I have the word ADDRESS in my spreadsheet showing up
about 100 times. I'd like to scan through the whole spreadsheet and
delete 3 rows after each word ADDRESS


---
Message posted from http://www.ExcelForum.com/




alexm999[_65_]

Deleting rows
 
Thanks!! Did the trick

--
Message posted from http://www.ExcelForum.com


JMay

Deleting rows
 
Bob:
Based on your macro I set up a scenario and gave it a try. It work
perfectly, only somehow [at the end] it goes back to the beginning of the
range and deletes two additional rows, erroneously. Can you comment/alter
code to eliminate?
TIA,


"Bob Phillips" wrote in message
...
Why didn't you say?

Dim oFound As Range
Dim firstaddress

Set oFound = Cells.Find("ADDRESS")
If Not oFound Is Nothing Then
firstaddress = oFound.Address
Do
oFound.Offset(1, 0).Resize(3, 1).EntireRow.Delete
Set oFound = Cells.FindNext(oFound)
Loop While Not oFound Is Nothing And firstaddress <

oFound.Address
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"alexm999 " wrote in message
...
How do I loop it, I have the word ADDRESS in my spreadsheet showing up
about 100 times. I'd like to scan through the whole spreadsheet and
delete 3 rows after each word ADDRESS


---
Message posted from http://www.ExcelForum.com/






Tom Ogilvy

Deleting rows
 
Post your code.

If you are deleting rows, it should not find any more values. If you are
trying to start from a certain row and only process forward (down), then you
need to put in a check for the location of the found cell and possibly alter
the search parameters prior.

Explain how it can delete all the instances of the target, yet then delete
two more rows?

--
Regards,
Tom Ogilvy

"JMay" wrote in message
news:uJG%b.13272$TT5.3326@lakeread06...
Bob:
Based on your macro I set up a scenario and gave it a try. It work
perfectly, only somehow [at the end] it goes back to the beginning of the
range and deletes two additional rows, erroneously. Can you comment/alter
code to eliminate?
TIA,


"Bob Phillips" wrote in message
...
Why didn't you say?

Dim oFound As Range
Dim firstaddress

Set oFound = Cells.Find("ADDRESS")
If Not oFound Is Nothing Then
firstaddress = oFound.Address
Do
oFound.Offset(1, 0).Resize(3, 1).EntireRow.Delete
Set oFound = Cells.FindNext(oFound)
Loop While Not oFound Is Nothing And firstaddress <

oFound.Address
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"alexm999 " wrote in message
...
How do I loop it, I have the word ADDRESS in my spreadsheet showing up
about 100 times. I'd like to scan through the whole spreadsheet and
delete 3 rows after each word ADDRESS


---
Message posted from http://www.ExcelForum.com/









All times are GMT +1. The time now is 08:13 PM.

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