Hi,
I have a spreadsheet with around 900 rows and lots of sets of duplicates that I need to separate from each other and analyze. I need a macro to insert 3 blank rows after every set of 9 that can be identified by the text in the last row of column A which will include the words "Site 9".
Then I want to copy the value of the last row column A into the first inserted row and include the averages of all the values above in columns B to I.
In the second blank row I want to include the standard deviation.
The third inserted row should be left blank.
Here is a glimpse of how it looks:
Before macro:
<tbody>
</tbody>
After macro:
<tbody>
</tbody>
Right now I only have a macro for inserting rows as shown:
Sub Insert3Rows()
Dim c As Range
For Each c In Range("A2:A10000")
If c.Value Like "*Site 9*" Then
c.Offset(1, 0).EntireRow.Insert
c.Offset(1, 0).EntireRow.Insert
c.Offset(1, 0).EntireRow.Insert
End If
Next c
End Sub
Is there a simple way to combine everything so I can insert the blank rows, label column a and calculate average & standard deviation?
I have a spreadsheet with around 900 rows and lots of sets of duplicates that I need to separate from each other and analyze. I need a macro to insert 3 blank rows after every set of 9 that can be identified by the text in the last row of column A which will include the words "Site 9".
Then I want to copy the value of the last row column A into the first inserted row and include the averages of all the values above in columns B to I.
In the second blank row I want to include the standard deviation.
The third inserted row should be left blank.
Here is a glimpse of how it looks:
Before macro:
A | B |
Stage Label | Total Cells |
A01 : Site 1 | 261 |
A01 : Site 2 | 177 |
A01 : Site 3 | 46 |
A01 : Site 4 | 66 |
A01 : Site 5 | 118 |
A01 : Site 6 | 123 |
A01 : Site 7 | 39 |
A01 : Site 8 | 23 |
A01 : Site 9 | 93 |
A02 : Site 1 | 472 |
A02 : Site 2 | 370 |
A02 : Site 3 | 398 |
A02 : Site 4 | 296 |
A02 : Site 5 | 266 |
A02 : Site 6 | 320 |
A02 : Site 7 | 153 |
A02 : Site 8 | 164 |
A02 : Site 9 | 362 |
<tbody>
</tbody>
After macro:
A | B |
Stage Label | Total Cells |
A01 : Site 1 | 261 |
A01 : Site 2 | 177 |
A01 : Site 3 | 46 |
A01 : Site 4 | 66 |
A01 : Site 5 | 118 |
A01 : Site 6 | 123 |
A01 : Site 7 | 39 |
A01 : Site 8 | 23 |
A01 : Site 9 | 93 |
A01 average | 105.11111 |
A01 std dev | 76.025398 |
A02 : Site 1 | 472 |
A02 : Site 2 | 370 |
A02 : Site 3 | 398 |
A02 : Site 4 | 296 |
A02 : Site 5 | 266 |
A02 : Site 6 | 320 |
A02 : Site 7 | 153 |
A02 : Site 8 | 164 |
A02 : Site 9 | 362 |
A02 average | 311.22222 |
A02 std dev | 105.16389 |
<tbody>
</tbody>
Right now I only have a macro for inserting rows as shown:
Sub Insert3Rows()
Dim c As Range
For Each c In Range("A2:A10000")
If c.Value Like "*Site 9*" Then
c.Offset(1, 0).EntireRow.Insert
c.Offset(1, 0).EntireRow.Insert
c.Offset(1, 0).EntireRow.Insert
End If
Next c
End Sub
Is there a simple way to combine everything so I can insert the blank rows, label column a and calculate average & standard deviation?
Last edited: