View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default marco that inserts rows?

You could use a macro to accomplish that. Change the sheet and range
reference as needed.

Sub test()
Dim rngData As Range
Dim rngInsert As Range
Dim rngCell As Range

Set rngData = Sheets("Sheet1").Range("A1:A10")

For Each rngCell In rngData.Cells
If UCase(rngCell.Value) = "M" And _
UCase(rngCell(2, 1).Value) = "P" Then
If rngInsert Is Nothing Then
Set rngInsert = rngCell(2, 1)
Else
Set rngInsert = Union(rngInsert, _
rngCell(2, 1))
End If
End If
Next rngCell

If Not rngInsert Is Nothing Then _
rngInsert.EntireRow.Insert

End Sub


"lloydyleg11" wrote:

Hi,
I have a worksheet with a column that has either a M, P or X in it. When
ever there is a M followed by a P i would like to insert a new row between
the two.
Any suggests or help would be great!
Cheers