Insert Row

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi Mohamed

Do you mean if a value in column B is the same as the value immediately below, insert a row between them? If so, try the following

Code:
Sub InsRows()
Dim i, x

x = Worksheets("Sheet3").UsedRange.Rows.Count

For i = x To 2 Step -1

    If Range("B" & i).Value = Range("B" & i).Offset(-1).Value Then
        Range("B" & i).EntireRow.Insert
    End If
Next i

End Sub

If that is not what you want, you will need to explain a little more.
 
Upvote 0
hi steve,

i have data in cell A1, A2, A3, A4, A5, .....
ABC
1Nibras
2Steve
3Mohamed
4Friend
5Wife
6Sister

<tbody>
</tbody>
then after i need
ABC
1Nibras
2Nibras
3
4Steve
5Steve
6
7Mohamed
8Mohamed
9
10Friend
11Friend
12
13Wife
14Wife
15
16Sister
17Sister

<tbody>
</tbody>
do you got it
 
Upvote 0
If all of your data are constants (that is, as long as there are no formulas on the sheet), then you can user this macro...
Code:
[table="width: 500"]
[tr]
	[td]Sub DoubleUpAndSeparate()
  Dim R As Long, C As Long, X As Long, Data As Variant, Result As Variant
  Data = Range("A1:E" & Cells(Rows.Count, "A").End(xlUp).Row)
  ReDim Result(1 To 3 * UBound(Data, 1), 1 To UBound(Data, 2))
  X = -2
  For R = 1 To UBound(Data, 1)
    X = X + 3
    For C = 1 To UBound(Data, 2)
      Result(X, C) = Data(R, C)
      Result(X + 1, C) = Data(R, C)
    Next
  Next
  Range("A1").Resize(UBound(Result, 1), UBound(Result, 2)) = Result
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,280
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top