random draw

dwmoh

New Member
Joined
Nov 13, 2017
Messages
3
Hello
in "feuil1" I have btn Draw when click in it I want to display the result in the feuil2 but there is an error in : "Range("E3").Resize(Tirag.Count) = Application.Transpose(Tirag.Items)"
******
Sub tirage()
Dim Tirag As Object
Dim Nbr As Long


Set Tirag = CreateObject("Scripting.Dictionary")
Sheets("Feuil2").Range("E3:E10").ClearContents
If Application.CountA(Sheets("feuil2").Range("A2:C2")) <> 3 Or [A2] > ([C2] - [B2] + 1) Then Exit Sub
While Tirag.Count < [A2]
Randomize Timer
Nbr = Int(([C2] - [B2] + 1) * Rnd + [B2])
Tirag(Nbr) = Nbr
Wend


Range("E3").Resize(Tirag.Count) = Application.Transpose(Tirag.Items)
End Sub



******
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Could you explain the purpose of the code, and typical values in A2/B2/C2?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top