vba select case inputbox

发布时间 2023-12-23 23:12:49作者: paoPaoLong_liu
Sub test()
    'MsgBox
    Message = "Please Input:"
    Title = "InputBox Demo"
    DefaultValue = 1   ' Set default value.
    ' Display message, title, and default value.
    x = InputBox(Message, Title, DefaultValue)
    Select Case x
        Case 1
            y = x * 1
        Case 2
            y = x * 2
        Case 3 To 5
            y = x * 3
        Case Is > 5
            y = x * 5
        Case Else
            y = 0
    End Select
    MsgBox "x=" & Str(x) & " y= " & Str(y)
End Sub