Thread: Insert 3 rows
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Sandy Mann Sandy Mann is offline
external usenet poster
 
Posts: 2,345
Default Insert 3 rows

I also assumed that 1 was the only piece of data in the start of a set, if not replace the 1 in the If/Then line with the full data entry, enclosed in quotes if it is text.

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


with @tiscali.co.uk


"Sandy Mann" wrote in message ...
Murph,

Try this code on a COPY of your spreadsheet. I assumed that the "1" was a figure 1 not a text representation of a 1. If it is text then enclose the 1 in the If/Then line in quotes .

Sub TripleInsert()
Dim EndRow As Long
Dim x As Long

EndRow = Cells(Rows.Count, 1).End(xlUp).Row

For x = EndRow To 4 Step -1
If Cells(x, 1).Value = 1 Then
Cells(x, 1).Resize(3, 1).EntireRow.Insert
Range(Cells(x + 2, 1), Cells(x + 2, 37)).Value = _
Range("A2:AK2").Value
End If
Next x
End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


with @tiscali.co.uk


"Murph" wrote in message ...
I just looked at the post trying to explain the query and the format has not come across so I will try a verbal explanation.
Cell A2 to Cell AK2 contain the header row, Row 1 is blank and left for further entry.
Cell A3 has the first case of a set of data across to AK3.
Cell A3 will always have a "1", A4 will always be "2" and the series of that set of data could be up to "24" which will Cell A26. If there are only 6 rows for that series of data that would be cell A8. In that case CellA9 would start a new series and the number in CellA9 would be the beginning of a new series starting with "1".
In the case of the next series I want to insert 3 rows before the "1", Past the header over the new series and go on down the page until up to 10 series of data are separated and given headings above their specific case.
One way I thought I could achieve the result was looking in each row from A4 and sutracting the previous cell from that cell. If the result is a negative insert the 3 entire rows. Alas I fail to get anything happening.
Hope that fixes the explanation and you are able to ignore previous mail.
Thanks for any help!