r/excelevator • u/excelevator Excel • Dec 03 '16
VBA Macro - Write Random numerical values to a range of cells
- Create a Name Range of your cells, for non contiguous cells hold down ctrl to select each cell and type the new range name in the address bar or use Name Manager.
- Copy the macro below into the worksheet module (alt+F11)
- Run the macro to insert random numbers into each cell in the range
.
Sub randomise()
'Reddit.com/u/excelevator
For Each cell In Range("myRange") '<== edit name of range here as required
cell.Value = WorksheetFunction.RandBetween(1, 1000) '<== edit range of random value here
Next
End Sub
1
Upvotes