Hi, I need to be able to randomly select 2 cells in a row from a list. For example:
Name | Age
Jim | 30
Peter | 25
Angela | 22
I have the macro below which can randomly select the name into varRandomItems(i) but I need to be able to also select the age from the neighbouring cell as well. Can anyone see how it could be modified? Many thanks.
Sub PickRandomItemsFromList()
Const nItemsToPick As Long = 5
Const nItemsTotal As Long = 3
Dim rngList As Range
Dim varRandomItems() As Variant
Dim i As Long
Set rngList = Range("A1").Resize(nItemsTotal, 1)
ReDim varRandomItems(1 To nItemsToPick)
For i = 1 To nItemsToPick
varRandomItems(i) = rngList.Cells(Int(nItemsTotal * Rnd + 1), 1)
Next i
End Sub
Bookmarks