Consulting

Results 1 to 7 of 7

Thread: Solved: Inputbox Display Lines?

  1. #1
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location

    Solved: Inputbox Display Lines?

    Hi all, i have an input box as shown below, it works fine, except i can only get the inputbox to display the first 4 lines, i.e it will not display "38 Pink" everything else it displays, does anyone know how to fix this?[VBA]IBS = Application.InputBox("Enter Colour to Delete" & vbCrLf & _
    Space(5) & "3 = Red" & vbCrLf & _
    Space(5) & "4 = Green" & vbCrLf & _
    Space(5) & "5 = Blue" & vbCrLf & _
    Space(5) & "6 = Yellow" & vbCrLf & _
    Space(5) & "38 = Pink", "Colour Deletion Selection", Type:=1)[/VBA]Regards,
    Simon

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I guess you've passed the InputBox size limits. Why not create a UserForm for your input?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Quote Originally Posted by Simon Lloyd
    Hi all, i have an input box as shown below, it works fine, except i can only get the inputbox to display the first 4 lines, i.e it will not display "38 Pink" everything else it displays, does anyone know how to fix this?[vba]IBS = Application.InputBox("Enter Colour to Delete" & vbCrLf & _
    Space(5) & "3 = Red" & vbCrLf & _
    Space(5) & "4 = Green" & vbCrLf & _
    Space(5) & "5 = Blue" & vbCrLf & _
    Space(5) & "6 = Yellow" & vbCrLf & _
    Space(5) & "38 = Pink", "Colour Deletion Selection", Type:=1)[/vba]Regards,
    Simon
    Must choose a value otherwise box will stay until you give input. Try 5555 and box is cleared because not in values that are allowed.

    [vba]Sub input_boxes()
    Dim ibs As String
    Dim message As String
    Dim heading As String
    message = "Enter Colour to Delete" & vbCrLf & _
    Space(5) & "3 = Red" & vbCrLf & Space(5) & "4 = Green" & vbCrLf & _
    Space(5) & "5 = Blue" & vbCrLf & _
    Space(5) & "6 = Yellow" & vbCrLf & _
    Space(5) & "38 = Pink"
    heading = "Colour Deletion"
    Do While ibs = vbNullString
    ibs = InputBox(message, heading)
    If ibs = "3" Or ibs = "4" Or ibs = "5" Or ibs = "6" Or ibs = "38" Then
    Exit Do
    End If
    ibs = ""
    Loop
    MsgBox (ibs & " was chosen")
    End Sub[/vba]

    Charlize

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Charlize, I think you missed the point of ther question.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    MD, i take your comment on board about the userform, it was just me being lazy as i had already created the input box and just wanted to display all that i had written neatly. I have now edited it to show just 4 lines of text now not as neat but minimal work!

    Charlize, thanks for your efforts and revised code, i guess i did miss that about the user not selecting a number and it does give an error (theres me again no error handling and blind to it!), i wont use you code unless i have to i will try to build the error handling myself taking into account your example.

    Thanks very much!

    Regards,
    Simon

  6. #6
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    The Application.Inputbox appears to be restricted to 5 lines and 255 characters.

    More than 5 lines and the text is lost.
    More that 255 characters and the box doesn't even appear!

    You could use VBA's Inputbox function but the returned value will not automatically be restricted to a number, as there is no Type argument.
    Cheers
    Andy

  7. #7
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location

    inputbox with 5 lines ...

    Quote Originally Posted by mdmackillop
    Hi Charlize, I think you missed the point of ther question.
    Hello Md,

    I think the question was "want to show 5 lines of choises and the last one doesn't show up". I gave the answer for 5 lines with checking for a number that was on the list (if you type anything else, the box will remain until you give a number on the list). If that wasn't the question, then I'm sorry that I didn't understood it.

    I used inputbox. Simon used application.inputbox . Because I can't use type:=1 to say it must be a number, I have to find a solution for that.

    Charlize

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •