' Shuffle the elements of an array of any type' (it doesn't work with arrays of objects or UDT)Sub ArrayShuffle(arr As Variant) Dim index As Long Dim newIndex As Long Dim firstIndex As Long Dim itemCount As Long Dim tmpValue As Variant firstIndex = LBound(arr) itemCount = UBound(arr) - LBound(arr) + 1 For index = UBound(arr) To LBound(arr) + 1 Step -1 ' evaluate a random index from LBound to INDEX newIndex = firstIndex + Int(Rnd * itemCount) ' swap the two items tmpValue = arr(index) arr(index) = arr(newIndex) arr(newIndex) = tmpValue ' prepare for next iteration itemCount = itemCount - 1 NextEnd Sub
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.























