ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add 5 blank rows after Word (https://www.excelbanter.com/excel-programming/351016-add-5-blank-rows-after-word.html)

Elaine

Add 5 blank rows after Word
 
How do I insert 5 blanks after the word Books has been used.

I have about 6000 rows in my spreadsheet and there was supposed to be a
total cost. In col A there are lots of blank rows except where words such as
"Books" or "Total Books" or sometimes "Text Books" appear.

Where the word "Book" appears, I would like to add 5 rows below that word.
Thank you.

--Elaine

Ron de Bruin

Add 5 blank rows after Word
 
Try this for column A

Sub test2()
Dim Rng As Range
Dim findstring As String
findstring = "Books"
Set Rng = Range("A:A").Find(What:=findstring, After:=Range("A" & Rows.Count), _
LookAt:=xlPart)
While Not Rng Is Nothing
Rng.Offset(1, 0).Resize(5, 1).EntireRow.Insert
Set Rng = Range("A" & Rng.Row + 1 & ":A" & Rows.Count) _
.Find(What:=findstring, After:=Range("A" & Rows.Count), _
LookAt:=xlPart)
Wend
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Elaine" wrote in message ...
How do I insert 5 blanks after the word Books has been used.

I have about 6000 rows in my spreadsheet and there was supposed to be a
total cost. In col A there are lots of blank rows except where words such as
"Books" or "Total Books" or sometimes "Text Books" appear.

Where the word "Book" appears, I would like to add 5 rows below that word.
Thank you.

--Elaine





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

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