I am working on a VBA module to create tables populated with randomly generated values. As part of this, for a column called 'Customer Name' I am selecting random values from a range of values between "Customer 1" and "Customer 50" which are stored in a column in a "Values" worksheet.
My code is below:
For CustomerName = 1 To Worksheets("TableCreate").Range("C5").Value
ActiveCell.Value = WorksheetFunction.Index(Worksheets("Values").Range("E2:E51"), _
WorksheetFunction.RandBetween(1, Worksheets("Values").Range("E2:E51").Rows.Count))
ActiveCell.Offset(1, 0).Select
Next CustomerName
This works perfectly, but it can pull duplicate values for Customer Name, and I want it to pull a list of unique customer names.