asyamonique
Well-known Member
- Joined
- Jan 29, 2008
- Messages
- 1,280
- Office Version
- 2013
- Platform
- Windows
Good Day,
Below code is shuffling column A1 name list randomly.
Is it possible to control the code from another worksheet?
I wanna place the button into different worksheet to hide main data.
What will be the add into that code?
Many Thanks
Below code is shuffling column A1 name list randomly.
Is it possible to control the code from another worksheet?
I wanna place the button into different worksheet to hide main data.
What will be the add into that code?
Many Thanks
VBA Code:
Sub ruffle_Button1_Click()
Dim r As Long, c As Long, RandomIndex As Long, Data As Variant, Result As Variant
For i = 1 To 500
Randomize
Data = Range("A1").CurrentRegion.Value
ReDim Result(1 To UBound(Data, 1), 1 To UBound(Data, 2))
For r = UBound(Data, 1) To 1 Step -1
RandomIndex = Int(r * Rnd + 1)
For c = 1 To UBound(Data, 2)
Result(r, c) = Data(RandomIndex, c)
Data(RandomIndex, c) = Data(r, c)
Next
Next
Range("A1").CurrentRegion = Result
Next
End Sub