Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default REpeating Values

Hello,

I have some code that generates Random draw winners, but if a name is
repeated in the list I want to have a pop-up identifing this and ask me if I
want the name changed or kept the same, this is just in case there is only 1
entry with 3 prizes.

I have placed the code below (I know it is messy but this is the only way I
know how to write code)

Please help

Application.Goto Reference:="Random_Number_Generator"
ActiveCell.FormulaR1C1 = "=ROUND((RAND()*(1-" & ValueMAM & ")+" &
ValueMAM & "),0)"
Application.Goto Reference:="MAM_Winner_1"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_1"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Reference:="MAM_Winner_2"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_2"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Reference:="MAM_Winner_3"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_3"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default REpeating Values

the basic approach would be:

After you make the entry, then check if it is a duplicate:

if Application.Countif(Range("A1:A50","John")) 2 then


In corporate something like that in your code.

--
Regards,
Tom Ogilvy



"GBH99" wrote:

Hello,

I have some code that generates Random draw winners, but if a name is
repeated in the list I want to have a pop-up identifing this and ask me if I
want the name changed or kept the same, this is just in case there is only 1
entry with 3 prizes.

I have placed the code below (I know it is messy but this is the only way I
know how to write code)

Please help

Application.Goto Reference:="Random_Number_Generator"
ActiveCell.FormulaR1C1 = "=ROUND((RAND()*(1-" & ValueMAM & ")+" &
ValueMAM & "),0)"
Application.Goto Reference:="MAM_Winner_1"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_1"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Reference:="MAM_Winner_2"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_2"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Reference:="MAM_Winner_3"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_3"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default REpeating Values

Hi Tom,

I have tried this and when I added the MSG box in I add a select case
option. Should I be using something else? I have tried
if Application.Countif(Range("A1:A50","John")) 2 then
MSGBOX DUPERR("Duplicate, Replace?",VBYesNo,"Replace")
Select Case DUPERR
Case 6
ActiveCell.clearcontents
'then I have put the code to create the cell entry again.
Case 7
MSGBOX "Continuing"

"Tom Ogilvy" wrote:

the basic approach would be:

After you make the entry, then check if it is a duplicate:

if Application.Countif(Range("A1:A50","John")) 2 then


In corporate something like that in your code.

--
Regards,
Tom Ogilvy



"GBH99" wrote:

Hello,

I have some code that generates Random draw winners, but if a name is
repeated in the list I want to have a pop-up identifing this and ask me if I
want the name changed or kept the same, this is just in case there is only 1
entry with 3 prizes.

I have placed the code below (I know it is messy but this is the only way I
know how to write code)

Please help

Application.Goto Reference:="Random_Number_Generator"
ActiveCell.FormulaR1C1 = "=ROUND((RAND()*(1-" & ValueMAM & ")+" &
ValueMAM & "),0)"
Application.Goto Reference:="MAM_Winner_1"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_1"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Reference:="MAM_Winner_2"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_2"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Reference:="MAM_Winner_3"
ActiveCell.FormulaR1C1 =
"=vlookup(Random_Number_Generator,MAMDraw!A:B,2,0) "
SendKeys "{f2}" & "{Enter}", True
Application.Goto Reference:="MAM_Winner_3"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
repeating values Peach Excel Worksheet Functions 1 November 29th 09 02:45 AM
repeating values [email protected] Excel Worksheet Functions 2 June 12th 08 04:55 PM
can i stop repeating values? Haitham Excel Discussion (Misc queries) 2 August 3rd 06 09:01 AM
excluding repeating values neda5 Excel Discussion (Misc queries) 2 July 10th 05 11:59 PM
Repeating Values Elaine Excel Programming 3 March 1st 05 06:47 PM


All times are GMT +1. The time now is 06:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"