VBA Choose 関数は、引数リストから指定された数値の値を返します。
Choose(数値、値_1、値_2、値_3など)
「choice」変数に書かれた数字により3つの値のいずれかを表示:
Sub ChooseExample1()
choice = 1
course = Choose(choice, "Excel", "VBA", "Google Sheets")
MsgBox "選択したコース:" & course 'メッセージを返します:「選択されたコース: Excel」
End Sub
Choose 関数の代わりに、配列 (Array) を使用することもできます。
Sub ChooseExample2()
choice = 1
course = Array("Excel", "VBA", "Google Sheets")(choice)
MsgBox "選択したコース:" & course 'メッセージを返します:「選択されたコース: VBA」
End Sub