+ Reply to Thread
Results 1 to 9 of 9

Problem with Listbox and Combobox

  1. #1
    Registered User
    Join Date
    05-20-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    13

    Problem with Listbox and Combobox

    Hi,
    I am having some issues with getting some code working in Excel. I am trying create a sheet which tracks staff holidays and which allows entries to be recalled readily and edited/deleted.

    I have created a userform which contains a couple of buttons, a listbox and combobox. I want the list box to be populated by the data on the sheet (which will grow with time) and to be filterable using the combobox. The combobox will be populated by the entries in column A of the sheet. The idea is that a manager can load up (filter) the entries for a staff member (within the userform) and then edit/delete as required.

    I did have this working for a short period but now am completely stuck. I have attached the sheet and code that I have so far. I am not a VBA expert and, for the most part, my code is adapted from that which I find on the internet. This has always worked well but this time I find my self going round in circles and have been for about a week.

    Any help or comments that you can provide to get me back on track would be much appreciated.

    Steve

    EDIT: For information, this same question has been post at http://www.vbaexpress.com/forum/show...lem&highlight=. I hadn't received any feedback and so expanded my search.
    Attached Files Attached Files
    Last edited by gloopy; 06-16-2015 at 07:31 AM.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem with Listbox and Combobox

    the named ranged "booked" had a ref error
    after making it
    =OFFSET(Holidays!$A$3,0,0,(COUNTA(Holidays!$A:$A)-1),8)
    it seems to work?
    was that the problem?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    05-20-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    13

    Re: Problem with Listbox and Combobox

    Many thanks for getting back to me. The defined name range error would certainly explain why this was working and then suddenly stopped. I agree, with this now corrected and a silly combobox reference error correction this now works. It has however highlighted another irritating flaw. The combobox now appears to pick up the adjacent cell values!! This is new and not seen before. Any thoughts on how this can be fixed?

    I have attached the revised file.

    Your help is much appreciated.


    Steve
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem with Listbox and Combobox

    what is the combobox1 meant to show?
    just person 1-2-3 all the time?

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

    Re: Problem with Listbox and Combobox

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  6. #6
    Registered User
    Join Date
    05-20-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    13

    Re: Problem with Listbox and Combobox

    Thanks Kyle for the feedback. Your comments make sense and I will bear this in mind for the future. I should emphasise at this point that wasting individuals time was not my objective but to simply maximise access to the wider VBA community. I can of course now see the issue with this and will amend my original post accordingly.


    Steve

  7. #7
    Registered User
    Join Date
    05-20-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    13

    Re: Problem with Listbox and Combobox

    Hi Humdingaling
    The combobox is meant to simply display the entries that are found in the first column of the list box. This seems to work initially but after 1 or 2 tries, it starts to display the dates in the adjacement cells. For now I expect it to simply show person 1-2-3. In time as more people take leave, the box will accommodate this by showing person 1-2-3-4-5-6.....
    I originally had the list box containing a fixed list of staff members but ran in to trouble when the listbox didn't contain some of those names because they hadn't booked any leave yet. Having the combobox update itself depending on what was in the listbox seemed like the right solution.

    Many thanks
    Steve

  8. #8
    Registered User
    Join Date
    05-20-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    13

    Re: Problem with Listbox and Combobox

    I have resolved my issue. the error highlighted above a simple typo were causing the trouble. Thanks Humdingaling - I am not sure I woud have found that error.

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem with Listbox and Combobox

    For now I expect it to simply show person 1-2-3
    if this is the case...why would you want to update the combobox on change?
    when you initialise the form its already there....adding items just confuses the situation?

    this whole section could just be deleted

    Please Login or Register  to view this content.

+ 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. Listbox filtering by combobox and listbox navigation
    By bufoss in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2015, 02:36 PM
  2. ComboBox & ListBox
    By ahneel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2013, 11:43 AM
  3. [SOLVED] filling listbox from userform combobox problem
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 07-13-2013, 03:48 AM
  4. Replies: 2
    Last Post: 12-07-2012, 02:10 AM
  5. Combobox/listbox
    By FSt1 in forum Excel General
    Replies: 4
    Last Post: 01-04-2005, 03:06 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