Unknown # cells need to be in one column - Macro

K

kenlyn

Somebody must be smarter than I ... that I know.

I have the following data in an excel sheet:
Columns
A B
JK 3
BK 1
PS 2

Where Column A is the names of employees, which has an unknown number
of rows and column B is the # of raffles they won - the number of
raffles they win changes. I am trying to write a macro that does this
.... put the number of raffles in column C in a row ...

C
JK
JK
JK
BK
PS
PS

Once this is done - i have a random number generator pick from this
list ....

Thanks a bunch - to the many of you smarter than I.

Excel 2003

Kenlyn T. Gretz
 
A

Ardus Petus

'-----------------------------------------------
Sub GenRandom()
Dim rSrc As Range
Dim rDest As Range
Dim iRpt As Integer

Set rDest = Range("C1")
For Each rSrc In Range( _
Range("A1"), _
Cells(Rows.Count, "A").End(xlUp))

For iRpt = 1 To rSrc.Offset(0, 1)
rDest.Value = rSrc.Value
Set rDest = rDest.Offset(1, 0)
Next iRpt
Next rSrc
End Sub

'-----------------------------------------------

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top