ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Inserting a single row to separate data multiple times (https://www.excelbanter.com/excel-discussion-misc-queries/139642-inserting-single-row-separate-data-multiple-times.html)

Luthdawg

Inserting a single row to separate data multiple times
 
How do I insert a row for every change in value for column C?

I need it to separate data
Currently I sort the spreadsheet and then scroll thru the entire thing
inserting rows for each variable listed in column C.

Example: Value in rows 1 thru 5 of column C are 27; and the value in rows 6
thru 8 are 28; rows 9 & 10 are 29 and so on and so on.

Dave Peterson

Inserting a single row to separate data multiple times
 
First add a header row if you haven't.

Then after you sort your data, select the data (header row through the last row
of data) and do:
Data|subtotals

And follow the wizard from there.

You can even add subtotals to columns/fields that you want!

Luthdawg wrote:

How do I insert a row for every change in value for column C?

I need it to separate data
Currently I sort the spreadsheet and then scroll thru the entire thing
inserting rows for each variable listed in column C.

Example: Value in rows 1 thru 5 of column C are 27; and the value in rows 6
thru 8 are 28; rows 9 & 10 are 29 and so on and so on.


--

Dave Peterson

Toppers

Inserting a single row to separate data multiple times
 
Try this:

Sub InsertRow()

With Worksheets("sheet1") '<=== change to suit
Lastrow = .Cells(Rows.Count, "C").End(xlUp).Row
For irow = Lastrow To 2 Step -1
If .Cells(irow - 1, "C") < .Cells(irow, "C") Then
Rows(irow).Insert Shift:=xlDown
End If
Next
End With
End Sub

"Luthdawg" wrote:

How do I insert a row for every change in value for column C?

I need it to separate data
Currently I sort the spreadsheet and then scroll thru the entire thing
inserting rows for each variable listed in column C.

Example: Value in rows 1 thru 5 of column C are 27; and the value in rows 6
thru 8 are 28; rows 9 & 10 are 29 and so on and so on.



All times are GMT +1. The time now is 03:03 PM.

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