Create VBA InputBox

  • Hi all,


    I am trying to create an inputbox using code from this site:




    I get an error on the first line that says, "Compile error: argument not optional". Can anyone help me with this?


    Thank you

  • Re: Create Inputbox


    Hi,


    By first line you mean this one?


    [vba]
    lNum = Application.InputBox _

    (Prompt:="Please enter you age.", _

    Title:="HOW OLD ARE YOU", Type:=1)


    [/vba]


    Try taking out the line breaks " _" and then put them back in:


    [vba]
    lNum = Application.InputBox(Prompt:="Please enter your age.",Title:="HOW OLD ARE YOU", Type:=1)


    [/vba]


    Then:


    [vba]


    lNum = Application.InputBox _
    (Prompt:="Please enter your age.", _
    Title:="HOW OLD ARE YOU", Type:=1)


    [/vba]


    Note you need to type <space> _ <Enter> for it to work.

  • Re: Create VBA InputBox


    Remove the extra line breaks.


    This:

    Code
    lNum = Application.InputBox _ 
     
    (Prompt:="Please enter you age.", _ 
     
    Title:="HOW OLD ARE YOU", Type:=1)


    Should look like this:

    Code
    lNum = Application.InputBox _ 
    (Prompt:="Please enter you age.", _ 
    Title:="HOW OLD ARE YOU", Type:=1)


    EDIT: Sorry, didn't read your reply... Just read what he said.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!