Hello Guys,
I need your help with injecting a duplicate checker within the code that I created.
Basically, this code generates random number from 0-5 and gives random emotion based from the number that was generated. Unfortunately, I want to make sure that these values will not be the same for each row to make it more "unique".
I tried to use "If" function but it only validates one cell at a time. Any help will be greatly appreciated.
I need your help with injecting a duplicate checker within the code that I created.
Basically, this code generates random number from 0-5 and gives random emotion based from the number that was generated. Unfortunately, I want to make sure that these values will not be the same for each row to make it more "unique".
I tried to use "If" function but it only validates one cell at a time. Any help will be greatly appreciated.
Code:
Dim wsRandomizer As Worksheet
Private Sub Randomizer_Click()
Dim word As String
Dim checker As Integer
Dim xlRange As range
Set wsRandomizer = ThisWorkbook.Worksheets("Randomizer")
Set xlRange = wsRandomizer.range("A2:A7")
Dim x As Integer
Dim y As Integer
Application.ScreenUpdating = False
x = 2
'wsRandomizer.range("ToClear").ClearContents
Do While wsRandomizer.Cells(x, 1).Value = "" And x <> 8
wsRandomizer.Cells(x, 1) = "=MOD(RAND()*100,5)"
wsRandomizer.Cells(x, 1) = Round(wsRandomizer.Cells(x, 1).Value, 0)
y = wsRandomizer.Cells(x, 1)
Select Case y
Case 5
word = "Happy"
wsRandomizer.Cells(x, 2) = word
Case 4
word = "Sad"
wsRandomizer.Cells(x, 2) = word
Case 3
word = "Sleepy"
wsRandomizer.Cells(x, 2) = word
Case 2
word = "Angry"
wsRandomizer.Cells(x, 2) = word
Case 1
word = "Confused"
wsRandomizer.Cells(x, 2) = word
Case 0
word = "Neutral"
wsRandomizer.Cells(x, 2) = word
End Select
x = x + 1
Loop
Application.ScreenUpdating = True
End Sub