+ Reply to Thread
Results 1 to 6 of 6

ListBox in a form - display one set of data, respond with another

  1. #1
    Registered User
    Join Date
    08-15-2013
    Location
    London
    MS-Off Ver
    Multiple versions
    Posts
    27

    Question ListBox in a form - display one set of data, respond with another

    I am working on a reusable Form with a listbox. When called it presents a series of multi-choice options that concatenate the selection back in a single string, and a "Write Back" button on the form passes that string back to the calling macro for placement in a cell.

    I've already had help with defining the list data at the point the form is called, which is brilliant. But now I want to refine my selections.

    I would like my listbox to contain a summary item explaining the selection, but the data written back should be a full-blown sentence. This would create a paragraph of pre-determined sentences that would be written into a cell within a printable worksheet.

    Each data set is currently defined as a Range - for example, one of them is "VideoChecks" and it looks like this:
    LISTBOX DISPLAY OUTPUT
    Video watched I have checked the video carefully.
    No problem I found nothing that contravenes my parameters for inclusion.
    Possible problem While the video does not contravene our standards, there is some content that may be questionable to some viewers.
    No Action We will not be taking any action with this video.
    Action required This video will be pulled from the list.

    I would like my Form's ListBox ("lstWhatColumns") to display the First Column, but use the second when building up the "Write Back" message.

    Thanks to Forum Guru Kyle123 my form's control currently looks like this:
    Please Login or Register  to view this content.
    lstWhatColumns is currently displaying just the first columns from the dataset (as ColumnCount = 1), but I don't know how to use the pick to return the corresponding full sentence that is in column 2.

    I have been trawling forums (fora?) trying to find a way to do this, but not seen anything (I can understand to be) relevant, so once again any assistance would be greatly appreciated.

    Kind regards

    Steve

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ListBox in a form - display one set of data, respond with another

    Like this:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: ListBox in a form - display one set of data, respond with another

    You can use a multi column list box and only display the 1st column.

    Standard module.
    Please Login or Register  to view this content.
    userform module
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    08-15-2013
    Location
    London
    MS-Off Ver
    Multiple versions
    Posts
    27

    Re: ListBox in a form - display one set of data, respond with another

    Thanks both, for your prompt responses.

    @Kyle - works like a charm again - thanks muchly.

    @Andy - I think I am reading this correctly; am I right in thinking that using your idea of a public definition of .ColumnCount and .ColumnWidths I could theoretically define those on calling the Form in the same way as I currently can with .List? Something along the lines of this (which doesn't work, I hasten to add):

    Please Login or Register  to view this content.
    If it's possible to do this, it would make it even more flexible, which is always a plus in my books!

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: ListBox in a form - display one set of data, respond with another

    You would need to set the listcolumns and listwidths before loading the listsource.

  6. #6
    Registered User
    Join Date
    08-15-2013
    Location
    London
    MS-Off Ver
    Multiple versions
    Posts
    27

    Re: ListBox in a form - display one set of data, respond with another

    GAH!! I can't believe I've just done that.

    TBH, I was creating the changes directly into my reply above, and then copied to overwrite my working macro so that I could test it (where there was no fail, but no perceivable change).

    When it didn't work I just immediately assumed it was yet another bit of arcane VBA knowledge I didn't know, rather than me just making a completely stupid and basic mistake.

    Sort the order out and it worked - posting back so if anyone else like me ever reads this thread it doesn't just end with a bit of my numpty-code:
    Please Login or Register  to view this content.

    Where's the "oh no, I am so embarrassed" emoticon when you need it?

    Thanks again

    KR

    Steve

+ 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. how to display data in listbox
    By biznez1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2013, 11:38 AM
  2. ListBox in Excel on basis of cell
    By nitesh_greatie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2013, 02:22 AM
  3. [SOLVED] Listbox data display problem
    By Henry in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-11-2005, 08:00 PM
  4. display and change listbox data
    By Oreg in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-10-2005, 09:00 PM
  5. Multicolumn listbox data display
    By jbl25 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2005, 10:56 PM

Tags for this Thread

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