Limit range of values for integer

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

In VBA (used in Excel), is there a way to limit the range of values of
a variable. For example, if I want to have an integer but only have
it range from 1 - 100 in value, how would I do that.

Thanks, Alan
 
you could test for the value of the interger. something like this:

If i > 0 or <=100 then
'do something here
Else
MsgBox "Please pick integer in the range of 1-100"
End If


....you could also use a SELECT....CASE block
 
Back
Top