+ Reply to Thread
Results 1 to 14 of 14

Userform ComboBoxes

  1. #1
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Userform ComboBoxes

    Hi and thanks for looking,

    I've been messing around with some VBA code in a userform that has 5 Comboboxes in

    1st Combobox for the Persons name

    2nd Combobox is for the date

    3rd Combobox is for Hours

    in the next column

    4thCombobox is for the date

    5th Combobox is for Hours

    When all Comboboxes are populated it works fine

    however when I populate the 1st 3 Comboboxes and leave the other 2 empty it populates the value of the hours onto the sheet but at the same time the persons name in the cell goes blank.

    Its the same if I have the 1st, 4th & 5th populated and the others empty I get the same result

    is there anyway to fix this so that when a Combobox is blank it does not affect the outcome.

    hope I've explained it right

    heres the sheet totalPointsDB 1a.xls

    heres the VBA code
    Please Login or Register  to view this content.
    Many thanks

    Toonies
    Last edited by Toonies; 10-21-2011 at 04:47 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Problem with Userform ComboBoxes VBA

    Hi Toonies

    Which ComboBoxes CAN be left empty?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Re: Problem with Userform ComboBoxes VBA

    Hi jaslake

    The 1st Combobox always has to be populated (Top)

    then there are 2 boxes under that

    Date then Range

    and then 2 boxes to the right

    is it possible to date and range populated in the 1st set and the 2nd set blank and vicer verser and not have the Name cell on the sheet go blank.

    Whilst also keeping the option to populate them all and work, which it presently does.

    Toonies

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Problem with Userform ComboBoxes VBA

    Hi Toonies

    I've gotten this fixed (I think)
    not have the Name cell on the sheet go blank
    I don't know your process but it seems to me that Namebox2, CboMonth and CboReasons MUST be filled in while the other 2 (CboMonth1 and CboReasons1) could be left blank (both...not one or the other).

    Is my understanding correct?

  5. #5
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Re: Problem with Userform ComboBoxes VBA

    That sounds correct

    Toonies

  6. #6
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Re: Problem with Userform ComboBoxes VBA

    hi jaslake

    I would be interested in your possible Fix

    Toonies

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Problem with Userform ComboBoxes VBA

    Hi Toonies

    In the attached I've messed with only the code in "Private Sub cmdAdd_Click()". See it it does as you require. Let me know of issues.
    Attached Files Attached Files

  8. #8
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Re: Problem with Userform ComboBoxes VBA

    It does exactly as I need.

    May I ask is it possible to Have it vicer verser ie:

    if either or 2 sets of boxs were populated or empty

    Toonies

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Problem with Userform ComboBoxes VBA

    Hi Toonies

    So, you're asking:
    Namebox2 must be filled in any event

    However
    CboMonth could be empty (but not if CboReasons is filled)
    CboReasons could be empty (but not if CboMonth is filled)

    CboMonth1 could be empty (but not if CboReasons1 is filled)
    CboReasons1 could be empty (but not if CboMonth1 is filled)

    Or all except Namebox2 could be empty (which would have no affect on any other cells...I believe...haven't tested it).

    Is this your thinking?

  10. #10
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Re: Problem with Userform ComboBoxes VBA

    Namebox2 must be filled in any event

    However

    1. CboMonth, CboReasons, CboMonth1 and CboReasons1 could be all filled

    2. CboMonth and CboReasons could be filled (whilst CboMonth1 and CboReasons1 remain empty)

    3.CboMonth1 and CboReasons1 could be filled (whilst CboMonth and CboReasons remain empty)

    Hope I've explained it correctly

    Many thanks

    Toonies

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Problem with Userform ComboBoxes VBA

    Hi Toonies

    Didn't get a chance to pay attention to this today...will do so tomorrow.

  12. #12
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Re: Problem with Userform ComboBoxes VBA

    hi jaslake,

    I really appreciate you looking at this

    Many thanks

    Toonies

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform ComboBoxes

    Hi Toonies

    Try the attached. Again, I only messed with only the code in "Private Sub cmdAdd_Click()". See it it does as you require. Let me know of issues.
    Attached Files Attached Files

  14. #14
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Re: Userform ComboBoxes

    hi jaslake,

    that is perfect

    I'm slowly picking up VBA

    I will have a play around with your method

    you make it look so easy

    many thanks

    Toonies

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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