Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Insert A blank Row

I used the Insert a blank column function and it works
great, I was trying to work out how to modify it to insert
a blank row, in column B ther will be the word line, if it
finds that word I want it to insert a blank row after that
and then continue on to a maximum of x number of rows

Any Ideas

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Insert A blank Row

Hi Nigel

Example for column A

Sub test2()
' below the word
Dim Rng As Range
Dim findstring As String
findstring = "line"
Set Rng = Range("A:A").Find(What:=findstring, After:=Range("A65536"), LookAt:=xlWhole)
While Not Rng Is Nothing
Rng.Offset(1, 0).EntireRow.Insert
Set Rng = Range("A" & Rng.Row + 1 & ":A" & Rows.Count) _
.Find(What:=findstring, After:=Range("A65536"), LookAt:=xlWhole)
Wend
End Sub


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



"Nigel Bennett" wrote in message ...
I used the Insert a blank column function and it works
great, I was trying to work out how to modify it to insert
a blank row, in column B ther will be the word line, if it
finds that word I want it to insert a blank row after that
and then continue on to a maximum of x number of rows

Any Ideas

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Insert A blank Row

Here is my kick at it... Very similar to Ron's... You can define the sheet to
search


Set wks = ActiveSheet (or whatever sheet you want)
and the range to search
Set rngToSearch = wks.Range("B2:B10") 'Or whatever range you want....


Public Sub InsertRows()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFirst As Range

Set wks = ActiveSheet
Set rngToSearch = wks.Range("B2:B10")
Set rngFound = rngToSearch.Find("Line", , xlValues, xlPart)

If Not rngFound Is Nothing Then
Set rngFirst = rngFound
rngFound.EntireRow.Insert (xlDown)
Do
Set rngFound = rngToSearch.FindNext(rngFound)
rngFound.EntireRow.Insert (xlDown)

Loop Until rngFound.Address = rngFirst.Address
End If

End Sub

HTH

"Nigel Bennett" wrote:

I used the Insert a blank column function and it works
great, I was trying to work out how to modify it to insert
a blank row, in column B ther will be the word line, if it
finds that word I want it to insert a blank row after that
and then continue on to a maximum of x number of rows

Any Ideas

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
How can I insert a true blank inst. of a non-blank zero string MF Excel Worksheet Functions 2 October 30th 09 01:58 PM
Insert Blank Row Below Sub-Total? Miss Jenny Excel Worksheet Functions 6 June 6th 08 08:22 PM
Insert a BLANK value Jop Duyvendak Excel Worksheet Functions 6 January 26th 07 08:59 PM
Macro To Insert Blank Row? rtidrtid Excel Discussion (Misc queries) 1 February 3rd 06 03:00 PM
Insert blank row Annette[_3_] Excel Programming 1 January 29th 04 02:34 AM


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