Parameters with fixed set of possible values

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

How do I make a subroutine with a parameter that has a fixed set of
possible values? I want something similar to the box that pops up for a
boolean with only 'true' and 'false' options.

Also, is it possible to populate the pop up box with options such as
'red', 'blue' that correspond to values such as '1', '2'?
 
Aaron,

In Excel 2000 or later, you can use Enum type variables. For
example,

Public Enum MyEnum
Red = 1
Blue = 2
End Enum

Then, declare the argument to the procedure As MyEnum. For
example,

Sub Test(WhatColor As MyEnum)
' your code here
End Sub

Finally, you can use a value of the enum in the code that calls
the procedure.

Test WhatColor:=Blue


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Back
Top