Hello
I am stock. Help.
I added a columns for dates and when I click the button it stop working the button for reset.
My original worksheet was in Sheet2 and the vba code was working for it.
I left the original code but I don't know which one that I need to change so that it will work for the random in column for Room which B8:E35 which used to be A8:C35.
Thank you in advance
See attachment.
Sub pick_Random()
Sheets("Random Matrix").Unprotect "RD" '<----- Change as required
Dim i&, j&, k&, rng, rd(1 To 10000, 1 To 1)
Dim cell As Range
For Each cell In Range("I8:I20") ' change to actual range of random numbers
If Not IsEmpty(cell) Then
k = k + 1
rd(k, 1) = cell.Value
End If
Next
rng = Range("A8:C35").Value
Randomize
For i = 1 To UBound(rng)
For j = 1 To 3
If j <> 2 Then rng(i, j) = rd(Int(Rnd * k) + 1, 1)
Next
Next
Range("A8:C35").Value = rng
'add this for the allow users of this worksheet to: Format cells and Sort
With Sheets("Random Matrix") 'change it here
.Protect _
Password:="RD", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
AllowFormattingCells:=True, _
AllowSorting:=True
.EnableSelection = xlUnlockedCells
End With
Range("B1").Select
End Sub
Bookmarks