ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Unknown # cells need to be in one column - Macro (https://www.excelbanter.com/excel-discussion-misc-queries/90789-unknown-cells-need-one-column-macro.html)

[email protected]

Unknown # cells need to be in one column - Macro
 
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


Ardus Petus

Unknown # cells need to be in one column - Macro
 
'-----------------------------------------------
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
--
AP

a écrit dans le message de news:
...
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




[email protected]

Unknown # cells need to be in one column - Macro
 
AP - awesome... you are much smarter than I... thanks a bunch.

Kenlyn



All times are GMT +1. The time now is 03:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com