Inserting a row after every two rows in a list of points

  • Thread starter Thread starter mws89388
  • Start date Start date
M

mws89388

I have a list of points in an excel file that is as follows:
0.195062 -1.429289
0.195062 -1.429289
0.219444 -1.437452
0.219444 -1.437452
0.243825 -1.445616
0.243825 -1.445616
0.26822 -1.457892
0.26822 -1.465994
0.292601 -1.479351
0.292601 -1.488074

Is there a quick way to make the file look like this:
0.195062 -9.086782
0.195062 -9.587177

0.219444 -9.290192
0.219444 -9.775616

0.243825 -9.497057
0.243825 -9.968761

0.26822 -9.704681
0.26822 -10.163868

0.292601 -9.910387
0.292601 -10.358173

which basically inserts a blank row after every two rows of dat
points. This is only the first ten rows out of a list of 5000 so I wa
wondering if there was a quick way to do this without going through al
5000 points and hitting insert row every single time. Any help would b
appreciated, Thanks
 
Hi!

You can use a macro to insert the rows, like this example:

Sub AddRows()
ActiveCell.Offset(rowOffset:=3, columnOffset:=0).Activate
Do While ActiveCell > 0
ActiveCell.Rows.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(rowOffset:=3, columnOffset:=0).Activate
Loop
End Sub

Select the first cell in the range and then run the macro.

Best regards

Stefan Hägglund
Microsoft
 
Sorry, you have to change the first row to:
ActiveCell.Offset(rowOffset:=2, columnOffset:=0).Activate

/Stefan Hägglund
Microsoft


Stefan Hägglund said:
Hi!

You can use a macro to insert the rows, like this example:

Sub AddRows()
ActiveCell.Offset(rowOffset:=3, columnOffset:=0).Activate
Do While ActiveCell > 0
ActiveCell.Rows.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(rowOffset:=3, columnOffset:=0).Activate
Loop
End Sub

Select the first cell in the range and then run the macro.

Best regards

Stefan Hägglund
Microsoft
 
Back
Top