Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default I don't want to repeat the same number

how can I change a repeating number?
this is what I have so far.
Thank you!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
A = Cells(1, 1) + 2
Dim Rw, Col
Rw = Target.Row: Col = Target.Column
If Col < 2 Then Exit Sub
If Rw < 3 Or Rw A Then Exit Sub
If Cells(Rw, Col) = Cells(Rw, Col) Then
Cells(Rw, Col) = Int((A * Rnd) + 1)
Else: Exit Sub
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default I don't want to repeat the same number

Try these modifications

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Rw, Col

A = Cells(1, 1) + 2


Rw = Target.Row: Col = Target.Column


If Col < 2 Then Exit Sub
If Rw < 3 Or Rw A Then Exit Sub

For i = 0 To (A - Rw - 1)

For J = i + 1 To (A - Rw)

Do While Cells(Rw, Col).Offset(Rowoffset:=i, columnoffset:=0) = _
Cells(Rw, Col).Offset(Rowoffset:=J, columnoffset:=0)

Cells(Rw, Col).Offset(Rowoffset:=J, columnoffset:=0) = _
Int((A * Rnd) + 1)
Loop
Next J
Next i

End Sub


"Sean" wrote:

how can I change a repeating number?
this is what I have so far.
Thank you!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
A = Cells(1, 1) + 2
Dim Rw, Col
Rw = Target.Row: Col = Target.Column
If Col < 2 Then Exit Sub
If Rw < 3 Or Rw A Then Exit Sub
If Cells(Rw, Col) = Cells(Rw, Col) Then
Cells(Rw, Col) = Int((A * Rnd) + 1)
Else: Exit Sub
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default I don't want to repeat the same number

Joel,
Thank you for you reply. Let me explain what I am trying to do. I run a
Luck of the Draw Dart Tournament. Normally I use playing cards to pair up
the partners I would like to use excel. I have a masters draw (best players
draw cards first), then ladies, then men. if you have any suggestions I would
greatly appreciate it.
Thank you,

Sean
"Joel" wrote:

Try these modifications

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Rw, Col

A = Cells(1, 1) + 2


Rw = Target.Row: Col = Target.Column


If Col < 2 Then Exit Sub
If Rw < 3 Or Rw A Then Exit Sub

For i = 0 To (A - Rw - 1)

For J = i + 1 To (A - Rw)

Do While Cells(Rw, Col).Offset(Rowoffset:=i, columnoffset:=0) = _
Cells(Rw, Col).Offset(Rowoffset:=J, columnoffset:=0)

Cells(Rw, Col).Offset(Rowoffset:=J, columnoffset:=0) = _
Int((A * Rnd) + 1)
Loop
Next J
Next i

End Sub


"Sean" wrote:

how can I change a repeating number?
this is what I have so far.
Thank you!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
A = Cells(1, 1) + 2
Dim Rw, Col
Rw = Target.Row: Col = Target.Column
If Col < 2 Then Exit Sub
If Rw < 3 Or Rw A Then Exit Sub
If Cells(Rw, Col) = Cells(Rw, Col) Then
Cells(Rw, Col) = Int((A * Rnd) + 1)
Else: Exit Sub
End If
End Sub

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
repeat number multiple times Brenda from Michigan Excel Discussion (Misc queries) 4 May 7th 09 01:17 PM
Random cell/number and dont repeat selected cell/number Hector PR Excel Discussion (Misc queries) 0 October 16th 06 05:02 PM
repeat a formula same column same number of rows apart steveo Excel Discussion (Misc queries) 1 July 9th 06 09:54 AM
Repeat statements "x" number of times... Frantic Excel-er Excel Discussion (Misc queries) 14 July 1st 05 04:19 PM
how do I get a calculation to repeat various number of times? weelittlekim Excel Worksheet Functions 1 October 27th 04 08:13 PM


All times are GMT +1. The time now is 03:20 PM.

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"