aburamewolf
Technical User
I would really appreciate some help right now, it's my first attempt at working with random numbers in VBA.
I'm working in a "raffle" program who's end result should be employees inputting their employee number, which in turn will trigger a look-up for their name and hence a row number can be obtained.
In that row there will be pre-assigned categories for that agent to fall under such as: ladies, guys, top performers, seniority, etc...
So once I have randomize a category to be selected, I would need the macro to go to the "Prize" sheet and according to the category chosen select a range which will contain a list of prizes that are eligible for that category only.
I found a way to generate that random number using
LRandomNumber = Int((3 - 1 + 1) * Rnd + 1)to generate a limit to the random numbers that can be generated (I've tested it by throwing the input into a textbox to see the number output and it is working) but I can't really find a way to make good usage of that number (I'm just brain frozen right now)
so right now the only functional part of code is this:
the categories would be stored columns C to F
(if a category has been left blank I would like it for that number to be re-randomized)
Any suggestion will be greatly appreciated!
I'm working in a "raffle" program who's end result should be employees inputting their employee number, which in turn will trigger a look-up for their name and hence a row number can be obtained.
In that row there will be pre-assigned categories for that agent to fall under such as: ladies, guys, top performers, seniority, etc...
So once I have randomize a category to be selected, I would need the macro to go to the "Prize" sheet and according to the category chosen select a range which will contain a list of prizes that are eligible for that category only.
I found a way to generate that random number using
LRandomNumber = Int((3 - 1 + 1) * Rnd + 1)to generate a limit to the random numbers that can be generated (I've tested it by throwing the input into a textbox to see the number output and it is working) but I can't really find a way to make good usage of that number (I'm just brain frozen right now)
so right now the only functional part of code is this:
Code:
Private Sub UserForm_activate()
Dim xvalue
Dim xrow As Long
xvalue = start1.anumber.Value
If xvalue <> "" Then
Sheets("agents").Select
xrow = Cells.Find(what:=xvalue, lookat:=xlWhole).Row
name1.Text = Cells(xrow, 2)
End If
End Sub
the categories would be stored columns C to F
(if a category has been left blank I would like it for that number to be re-randomized)
Any suggestion will be greatly appreciated!