Break one line item into many...
Someone at this DG gave me this macro back in January (or somewhere around
that time). Hope it works for you...
Sub InsertAnyRows()
Dim insertNumber As Range
Dim insertStart As Range
Dim redRng As Range
Dim i As Integer
Set insertNumber = Application.InputBox _
(Prompt:="Select a point to begin inserting rows. For instance, choose first
non blank cell in Column A", Title:="Add a row", Type:=8)
insertNumber.Select
If insertNumber <= 0 Then
MsgBox ("Invalid Number Entered")
Exit Sub
End If
Dim MyRow As Long
lastcell = Cells(Rows.Count, "A").End(xlUp).Row
MyRow = 1
Do Until MyRow = lastcell
For i = 1 To Cells(MyRow, 1)
If Cells(MyRow, 1) < "" Then
Cells(MyRow + 1, 1).Select
Selection.EntireRow.Insert shift:=xlDown
End If
Next
lastcell = Cells(Rows.Count, "A").End(xlUp).Row
MyRow = MyRow + 1
Loop
End Sub
All you have to do is split the data so that the number shows in Column A
and you can do this by the following method: Data Text to Columns.
Hope it works for you.
Ryan--
"Tom" wrote:
Is there a way or a script I can run to break out one line item into many?
For example
A B (columns)
2 A5285
3 A2358
I would like Excel to recognize that I want 2 lines created from colunm A
and fill A5285 into column B next to it. And subsequently I would like it to
recognize 3 and create three lines from it etc..etc.. So it would look as
below
A B
2 A5285
2 A5285
3 A2358
3 A2358
3 A2358
Thanks in advance!!
Tom
|