Is there a way to compare multiple variables in VBA? For instance:
Dim x As Integer
Dim y As Integer
Dim z As Integer
x = 99
y = 2
z = 3
I would like to return the smallest of the values. I understand that I could use select case x > yfor all possible permutations, but this seems cumbersome for more than three variables.
I tried the worksheet function
solution = Application.WorksheetFunction.Min(x, y, z)
but returns 2, and I would like it to return a variable name to pass to another function.
many thanks,
Edit: Sorry if this is confusing, but I'm still a newbie to VBA. Here my problem is a little more general:
, , . , , . ( 0 ). , 2 , if x>y then, , 3. .