MarkCBB
Active Member
- Joined
- Apr 12, 2010
- Messages
- 497
Hi there,
I have a Workbook with 2 worksheets, on Sheet1 there is a list of Competition winners, in Column A on Sheet1 there is a unique entry number. i.e. 123249. On Sheet2 there is a table column A consists of a Heading "#" then 1-26 under that until row 27. Column B has the heading Winners.
I am using the following Code to select 26 random numbers from Sheet1 and place then in the Sheet2 table.
However I get a formula error #NAME? I am not sure why this is happening? does anyone know?
I am also trying to find a way on ensuring that no duplicate numbers are selected? but I am not sure on how to approach this.
I am also new to VBA.
Using Excel 2010.
Thanks.
I have a Workbook with 2 worksheets, on Sheet1 there is a list of Competition winners, in Column A on Sheet1 there is a unique entry number. i.e. 123249. On Sheet2 there is a table column A consists of a Heading "#" then 1-26 under that until row 27. Column B has the heading Winners.
I am using the following Code to select 26 random numbers from Sheet1 and place then in the Sheet2 table.
Code:
Sub Winners()
Do
ActiveCell.FormulaR1C1 = "=RANDBETWEEN(MIN(Sheet2!A:A),MAX(Sheet2!A:A))"
ActiveCell.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
End Sub
However I get a formula error #NAME? I am not sure why this is happening? does anyone know?
I am also trying to find a way on ensuring that no duplicate numbers are selected? but I am not sure on how to approach this.
I am also new to VBA.
Using Excel 2010.
Thanks.