+ Reply to Thread
Results 1 to 14 of 14

Listbox items on a Userform to a worksheet

  1. #1
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Listbox items on a Userform to a worksheet

    Hi,

    I have a Userform with a listbox. I would like to transfer all items within this listbox to a cell in a worksheet.

    Please Login or Register  to view this content.
    Anyone any ideas on how to do this?

    Thanks

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Listbox items on a Userform to a worksheet

    Hi colin7
    Just checking I am reading correctly, "you want to transfer ALL items in a 'listbox' to a 'cell' "
    A copy of your 'workbook' would be useful to be able to give a solution suitable to your requirement.

  3. #3
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Listbox items on a Userform to a worksheet

    Hi Torachan,

    Yes listbox1 on my userform will be populated with items as follows;

    Programmes
    Site visits
    Method Statement
    Health and Safety

    I want to add this list of items to the 4th column in the table on the worksheet.

    lastrow.Range.Value = Array(TextBox1, TextBox2, TextBox3, ListBox1, TextBox4). This transfers all the textbox values ok but leaves the listbox blank

    Thanks
    Last edited by colin7; 02-14-2020 at 09:12 AM.

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Listbox items on a Userform to a worksheet

    How is your listbox initially populated ?

  5. #5
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Listbox items on a Userform to a worksheet

    Just add item like so

    listbox1.AddItem "Site Visits"
    listbox1.AddItem "Programmes"
    etc

    Then when I click command button on userform I want to add the list into the table on the worksheet.

    Thanks

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Listbox items on a Userform to a worksheet

    Rarely do I spend my time pursuing something that makes no sense to me.
    However what I have produced is my 'take' on the specification.
    I still do not see a purpose, if in the unlikely event I have translated the spec correct, please explain the reasons for the event.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Listbox items on a Userform to a worksheet

    Hi Torachan,

    Firstly thanks so much for taking the time to help me with this, it is much appreciated.

    You have nearly got it working the way I need but just a few wee tweaks hopefully.

    I have attached a file for you to see the outcome I am looking.

    Again thank you very much for your help!
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Listbox items on a Userform to a worksheet

    How about
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Listbox items on a Userform to a worksheet

    Torachan/Fluff13,

    Thanks to both of you for your help with this.

    Fluff13 your code works perfect. Just one thing. Sometimes I may not have 4 items in the listbox. There could be anything between 1 and 10 items in it depending on the particular Project.
    Your code works perfect when I have 4 items but if there is more than 4 it doesn't pick it up. Is this something easy enough to fix?

    Thank you

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Listbox items on a Userform to a worksheet

    How about
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Listbox items on a Userform to a worksheet

    Fluff13,

    This works perfectly now. Thanks very much to yourself and Torachan for all your help, I really appreciate it!

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Listbox items on a Userform to a worksheet

    You're welcome & thanks for the feedback

  13. #13
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Listbox items on a Userform to a worksheet

    Thanks for feedback.
    Still fascinated how the stored four liner is used within the wider program.
    As you have stated the number of items in the listbox will vary, why not store/feed from a sheet table rather than hard code, easier to maintain.

  14. #14
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Listbox items on a Userform to a worksheet

    Its quite complicated but it works for me. I have 20+ checkboxes on a Userform. When I click on the checkboxes required for that project it adds them items to the listbox. Once populated I click a command button to update several worksheets. There may be a better way of doing this but this seems to work quite well for me.

    Thanks again for your help, its much appreciated!

+ 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] Preselect items on a userform listbox
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 30
    Last Post: 04-18-2016, 05:57 AM
  2. Userform Selecting listbox items erroneously
    By pjwhitfield in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 05-25-2015, 04:11 PM
  3. [SOLVED] Colour items in Userform Listbox
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2014, 02:44 PM
  4. [SOLVED] Add Selected Items From One ListBox to Another ListBox on UserForm
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2014, 06:53 PM
  5. VBA edit listbox items on userform
    By Hilton1982 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2013, 03:51 AM
  6. loading ListBox row items to another UserForm
    By StartingOut in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-27-2012, 10:37 AM
  7. Transfer Selected UserForm ListBox Items into a new Row
    By oumomof3 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-25-2011, 02:02 PM

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