asking user to enter numbers and msg out these numbers -vba


Well-known Member
With a help from Fluff, I created the code below. It is asking user to enter 3 numbers then the code will msg out these 3 numbers. I want to improve this code. I do not want to limit user to enter only 3 numbers. I want a user to enter any number and I will create a loop depend on how many numbers user entered. Any help would be appreciated. Thank you.
' asking users to enter multiple numbers and then msgboxing them 1 by 1
Sub myarray()
    Dim x As Variant
    Dim i As Integer
    x = InputBox("enter 3 numbers like 1,2,3")
    x = Split(x, ",")
    For i = 0 To 2
        MsgBox "your number are  " & "number" & i + 1 & ">>  " & x(i)
    Next i
End Sub


MrExcel MVP, Moderator
For i = 0 To UBound(x)
        MsgBox "your number are  " & "number" & i + 1 & ">>  " & x(i)
    Next i

Some videos you may like

This Week's Hot Topics