View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Macro for Frequency Data

Sub ABC()
Dim rng As Range, cell As Range
Dim v As Variant, v1 As Variant
Dim s As String, s1 As String
Dim i As Long, j As Long
Set rng = Range(Cells(2, 1), Cells(2, 1).End(xlDown))
For Each cell In rng
v = Split(cell, ",")
v1 = Split(cell.Offset(0, 1), ",")
s1 = ""
For i = LBound(v) To UBound(v)
s = ""
For j = 1 To v1(i)
s = s & v(i) & ","
Next j
s1 = s1 & s
Next i
cell.Offset(0, 2).Value = Left(s1, Len(s1) - 1)
Next cell
End Sub

Obviously test on a copy of your data.

--
Regards,
Tom Ogilvy



"BWoods" wrote:

I'm looking for a macro that makes a single long list of data from 2 user
input columns of data (column A are the data values themselves & column B are
the frequencies of those values). Example - Col. A contains 1, 2, 3, and
Col. B contains 5, 6, 9. This is actually a data set of 20 values that
includes 5 number 1's, along with 6 number 2's, and 9 number 3's. I'd like
Column C to be this long list of 20 data values
(1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3).
Thanks