How to convert bin data to single column?

sm5007

New Member
Joined
Jan 24, 2004
Messages
1
Is there a way to convert data that is already binned to one single column of data? I have a few hundred lines of data that look like this:


Number - Freq.
1 - 5
2 - 3
3 - 2
.
.
.


I would like them converted back into a single column like this:

1
1
1
1
1
2
2
2
3
3


There are too many to do manually, so I need some way to automate it. Any suggestions? Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Assuming that your data is in Column A and there is nothing in Column B you could use this code

Code:
Sub binconv()
Dim R1 As Integer, R2 As Integer, MyNbr As Integer, MyCount As Integer, MyStr As String
Dim K As Integer
R1 = 1: R2 = 1
Do While Cells(R1, 1) <> ""
MyStr = Cells(R1, 1)
MyNbr = Val(Left(MyStr, InStr(MyStr, "-") - 1))
MyCount = Val(Right(MyStr, InStr(MyStr, "-"))) * -1
For K = 1 To MyCount
Cells(R2, 2) = MyNbr
R2 = R2 + 1
Next K
R1 = R1 + 1
Loop
End Sub

Afterward you can delete Column A if you no longer need it for anything.

HTH
 
Upvote 0

Forum statistics

Threads
1,226,456
Messages
6,191,144
Members
453,643
Latest member
adamb83

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