View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default I need some help with Arrays

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim LastRow As Long
Dim ary As Variant
Dim NumRows As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = LastRow To 2 Step -1

ary = Split(.Cells(i, "C"), ",")
If UBound(ary) LBound(ary) Then

NumRows = UBound(ary) - LBound(ary)
.Rows(i + 1).Resize(NumRows).Insert
.Cells(i + 1, "A").Resize(NumRows) = Cells(i, "A").Value
.Cells(i + 1, "B").Resize(NumRows) = Cells(i, "B").Value
.Cells(i, "C").Resize(NumRows + 1) =
Application.transpose(ary)
End If
Next i

End With

End Sub

--
__________________________________
HTH

Bob

"mikebres" wrote in message
...
I'm trying to get the data from this format:
MNO Sort ZONES IN SORT PROGRAM
23 80011 80011, 80042
47 80012 80012, 80041
53 80013 80013
33 80014 80014, 80044

To this Format:
MNO Sort ZONES IN SORT PROGRAM
23 80011 80011
23 80011 80042
47 80012 80012
47 80012 80041
53 80013 80013
33 80014 80014
33 80014 80044

So that each of the comma delimeted items in the last column is split out
to
it's own row, with the MNO and the Sort listed for each of the split
items.

Any ideas?

Thanks
Mike