For Barrie Davidson


Posted by Paul B on October 02, 2001 3:21 PM

Barrie you posted this Marco awhile back. Would you please modify it to show a input box so the number of rows to be inserted could be put in. Thanks

Sub Insert_row()
' Written by Barrie Davidson
Dim Number_of_rows As Long

Number_of_rows = ActiveSheet.UsedRange.Rows.Count
Range("A2").Select
Do Until Selection.Row = Number_of_rows + 1
If Selection.Value <> Selection.Offset(-1, 0).Value Then
Selection.EntireRow.Insert
Number_of_rows = Number_of_rows + 1
Selection.Offset(2, 0).Select
Else
Selection.Offset(1, 0).Select
End If
Loop

End Sub

Posted by Qroozn on October 02, 2001 3:59 PM


Paul,
i think u will find he has porsted the code with this option on the posting you were referring to. (this may be what you wanted)

Sub Insert_rows()
' Written by Barrie Davidson
Dim insertNumber As Integer
On Error Resume Next
Range("A1").Select
insertNumber = CInt(InputBox("Enter number of rows to insert"))
If insertNumber <= 0 Then
MsgBox ("Invalid Number Entered")
Exit Sub
End If
Do Until Selection.Value = ""
ActiveCell.Offset(1, 0).Range("A1:A" & insertNumber).Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(insertNumber, 0).Select
Loop
Range("A1").Select
End Sub



Posted by Barrie Davidson on October 03, 2001 8:54 AM

Thanks Qroozn :-) (nt)