+ Reply to Thread
Results 1 to 11 of 11

Userform with Listbox to lookup values in range - Spin Button Issue

  1. #1
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Userform with Listbox to lookup values in range - Spin Button Issue

    Hi all,

    I'm in need of some help with using listboxes and spinbutton to reorder in a listbox.

    So there are three issues I'm having here and I'll list them in level of importance (the order I need most help with)

    1) - I've never used spin buttons, however I want to be able to reorder the listbox values in listbox2. Listbox2 is currently populated from any of the options from listbox1 however I want to be able to reorder them once they've been moved over.

    2) - When I add/remove from a listbox with the last value selected it moves the entire contents over to the other listbox. I want it to work like it does if you select a value which is not the last in the list.

    3) - For a quick mock up I've used a different userform which only has a combobox to make a selection from. I have this coded to update in the file which is fine, however I'm not that confident with cycling through the whole list of items which will be in Listbox2. So any advice on this also would be greatly appreciated.

    Thanks in advance.
    Attached Files Attached Files
    Please do add reputation where you see fit, it's nice to be nice and we all enjoy a pat on the back

    Please also mark your thread as solved once it has been.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    Q1
    I want to be able to reorder the listbox values in listbox2
    How? What order do you want or do you mean you want to move the selected item up/down the list when clicked?

    Q2
    If an item is selected, then removing it will cause the ListBox to select the item above. Simple solution is unselect it before moving to the other listbox.
    Please Login or Register  to view this content.
    If the listbox is not going to be MultiSelect you can get away with referring to the ListIndex to copy/remove - that'll do away with the loop and make this issue go away as as consequence.

    Q3
    however I'm not that confident with cycling through the whole list of items which will be in Listbox2
    But you cycle though the whole list of items in ListBox1. Can you expand on this?
    Last edited by cytop; 07-13-2017 at 04:12 AM.

  3. #3
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    Thanks Cytop

    So Q1: Yes I want to reorder the items in Listbox2 by moving them up or down the list order

    Q2: The listbox won't be multiselect, so the user will have to select one by one from listbox1 to move over to listbox2, and then the same to remove from listbox2 to listbox1

    Q3: In userform1 I only have a combobox which once selected adds the column to right. However as I want to use the list of items to add extra columns in I don't know how to code it. So for combobox1 in userform1 I can simply use combobox1.value, however for Listbox2 I don't want to use the value selected, I want to add a new column in for every item in that listbox2. The cycling through items in ListBox1 is code I found online and used so my understanding of it is very low.

    Thanks again

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    Q1

    Something like this:
    Please Login or Register  to view this content.
    (Edit - code refers to ListBox1; you want ListBox2. Simple enough change)

    Q2
    If the listboxes are not multiselect then the Add code can be simplified:
    Please Login or Register  to view this content.
    Sorry - I don't understand Q3.
    Last edited by cytop; 07-13-2017 at 04:44 AM.

  5. #5
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    Q1 - Absolutely Nailed It! Thanks Cytop

  6. #6
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    Quote Originally Posted by PFDave View Post
    3) - For a quick mock up I've used a different userform which only has a combobox to make a selection from. I have this coded to update in the file which is fine, however I'm not that confident with cycling through the whole list of items which will be in Listbox2. So any advice on this also would be greatly appreciated.
    I've managed to resolve this myself now so thanks.

    Just 2) still a concern

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    How is Q2 still a concern?

  8. #8
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    Quote Originally Posted by cytop View Post
    Q1

    Q2
    If the listboxes are not multiselect then the Add code can be simplified:
    Please Login or Register  to view this content.
    Sorry - I don't understand Q3.
    I've resolved 3 myself, that was the population of the sheet for each item in the listbox2.list.

    Cytop you've saved me a chunk of time and increased my understanding. Thank you so much

  9. #9
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    Quote Originally Posted by cytop View Post
    How is Q2 still a concern?
    Didn't see your edited post. Thanks again, really appreciated

  10. #10
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    My fault then - I tend to answer questions with multiple parts bit by bit... must get out of that habit.

  11. #11
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Userform with Listbox to lookup values in range - Spin Button Issue

    Quote Originally Posted by cytop View Post
    My fault then - I tend to answer questions with multiple parts bit by bit... must get out of that habit.
    Don't you ever change

+ 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. Couln't link up with textbox to spin button in userform
    By ajaypal.sp in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-18-2016, 08:14 AM
  2. Min and Max limits on Spin Button (userform)
    By syedmehdi in forum Excel General
    Replies: 1
    Last Post: 04-14-2015, 01:39 PM
  3. [SOLVED] Help with Spin Button. Set Spin button starting value based on a text box value
    By etuckram in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-18-2014, 10:05 AM
  4. Display changes values in userform listbox from range with VBA
    By FlyingMouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2014, 10:49 PM
  5. [SOLVED] Userform spin button different way to display number of records
    By guitarsweety in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2014, 08:09 AM
  6. Excel spin button on Userform
    By OneSurya in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-08-2013, 02:19 PM
  7. Using Spin Button to Vertically Paginate ListBox
    By BeefNoodleSoup in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-16-2012, 09:52 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