+ Reply to Thread
Results 1 to 3 of 3

Equivalent to a populated InputBox or pop up Listbox

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Equivalent to a populated InputBox or pop up Listbox

    Hi All,

    I have a string separated by Chr(10) *alt enters. like below..

    Question1
    Question2
    *etc
    I am trying to get a listbox to pop up like an input box does so that I can choose which question to delete from that string. I currently have this input box but I would like it to be more rigorous so therefore that the user can Only select a question number in the string.

    DelQ = InputBox("Which Question number would you like to delete?", , "Question")
    Many thanks,
    ARowbot
    !If all your troubles are solved, then so is the thread. Show this by marking it so using thread tools at the top of the page.
    If I helped do this, then please show your appreciation by awarding rep points.
    <------ Button for that is over there

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Equivalent to a populated InputBox or pop up Listbox

    Sub Populate_Listbox()
    SplitArray = split(YourStringVariable,Chr(10)
    Sheet1.Listbox1.List = SplitArray
    End Sub
    The above will take the variable "YourStringVariable" and split it into an array called "SplitArray" before using that array to populate a listbox on Sheet1 Called Listbox1

    obviously you need to create the listbox etc first and change the above to whatever your details are but that will populate it.
    If someone has helped you then please add to their Reputation

  3. #3
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,178

    Re: Equivalent to a populated InputBox or pop up Listbox

    
    sWord = "larry" & Chr(10) & "moe" & Chr(10) & "Currly"
    
    delQ = InputBox("Which Question number would you like to delete?", "Delete Question")
    
    i = InStr(sWord, Chr(10))
    Q1 = Left(sWord, i - 1)
    
    j = InStrRev(sWord, Chr(10))
    Q3 = Mid(sWord, j + 1)
    Q2 = Mid(sWord, i + 1, j - i)
    
    Select Case delQ
      Case 1
        MsgBox "Delete: " & Q1
      Case 2
        MsgBox "Delete: " & Q2
      Case 3
        MsgBox "Delete: " & Q3
     Case Else
    End Select

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Populated Textbox by listbox only showing first record
    By roelof bakker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2014, 09:17 AM
  2. Fill out listbox with inputbox
    By sebastienkanj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2013, 10:27 AM
  3. Complex userform with user-populated listbox
    By olivierpbeland in forum Excel Programming / VBA / Macros
    Replies: 72
    Last Post: 01-23-2013, 04:18 PM
  4. [SOLVED] Avoid duplicates in a listbox populated using search keyword
    By sivakumar123 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-10-2013, 08:28 AM
  5. Replies: 2
    Last Post: 12-07-2012, 02:10 AM
  6. Error in populated listbox userform
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2010, 09:54 PM
  7. Add Items To RowSource Populated ListBox
    By radar_jynx in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-14-2009, 10:18 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1