vba select case inputbox

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

  

posted @ 2023-12-23 23:09  paoPaoLong_liu  阅读(20)  评论(0)    收藏  举报