+ Reply to Thread
Results 1 to 13 of 13

populating worksheet column from combobox

  1. #1
    Registered User
    Join Date
    09-03-2009
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    17

    populating worksheet column from combobox

    Hey all,
    New to this forum and need some help desparately on a couple of issues. I have a userform with comboboxes and listboxes etc. The comboboxes have drop down lists which are populated from data in columns from a worksheet.

    1.) During the execution of the userform, a value is selected from the combobox, which is place in a column on another worksheet. So far so good. If I select the same value again, nothing shows up in the row below the first selection. If I choose a different value it shows up. I have tried using different properties of the combobox but have not been able to get around this.

    2.) I would like, when the excel file is opened that the userform is ready to go, ie enter data. I have tried putting the code:

    Private Sub Workbook_Open()
    UserForm1.Show
    End Sub

    in "ThisWorkbook" module but have had no success with it.

    Thanks in advance
    Chris
    Last edited by chris_norton; 09-08-2009 at 01:42 PM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: populating worksheet column from combobox

    Could you upload your workbook? At least provide the full code attached to the combobox.

    As for opening the form when the workbook is opened - is "UserForm1" in fact the actual name of the user form?

    The code to open the form is correct. Are macros are being enabled when the file is opened?

  3. #3
    Registered User
    Join Date
    09-03-2009
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: populating worksheet column from combobox

    Palmetto,
    Thanks for the reply. Here's the code in question:

    Please Login or Register  to view this content.

    To answer your second question, no my userform is employee_daily, however that's what I used. I am enabling macros.

    Chris
    Last edited by chris_norton; 09-04-2009 at 01:02 AM.

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: populating worksheet column from combobox

    Your code for the combobox_click event is only writing to one column so I don't see why you are trying to find the last row in columns B & C, unless you have more code to add for writing values into those columns.

    Anyway you could use this if you are only writing to the last row in column-A.
    Please note I've used sheet code names and you may have to change the sheet reference.
    Please Login or Register  to view this content.
    To answer your second question, no my userform is employee_daily, however that's what I used.
    Then your workbook_open event should read:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: populating worksheet column from combobox

    Welcome to the forum, chris.

    Please take a few minutes to read the forum rules, and then edit your second post to change the QUOTE tags to CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    09-03-2009
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: populating worksheet column from combobox

    Palmetto,
    I tried your code and still the same result, except that on sheet2 after selecting my first pick, and then just clicking anywhere within the user form, that first pick value ended up in the next row a couple of columns over. Sheet6 didn't respond at all. I don't understand why you can't pick repeat values within a combobox and not have them show up in subsequent rows - doesn't make sense to me.

    Thanks
    Chris

  7. #7
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: populating worksheet column from combobox

    I tried your code and still the same result, except that on sheet2 after selecting my first pick, and then just clicking anywhere within the user form, that first pick value ended up in the next row a couple of columns over. Sheet6 didn't respond at all.
    That could not occur withthe code I gave you.
    It would be best if you uploaded your workbook so that we can see all of the code and structure.

    I don't understand why you can't pick repeat values within a combobox and not have them show up in subsequent rows - doesn't make sense to me.
    You can. See attached.

  8. #8
    Registered User
    Join Date
    09-03-2009
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: populating worksheet column from combobox

    Palmetto,

    That could not occur withthe code I gave you.
    It would be best if you uploaded your workbook so that we can see all of the code and structure
    .

    You're correct, in messing around with the properties, I set the control source for the combobox to f3. As soon as I removed it it stopped doing that

    So I tried what you sent, however I still can't successively pick the same name and have it show up in the next row in column header1? I can for instance pick "Shawn" then say pick "Ken O" then "Shawn" again:

    Shawn
    Ken O
    Shawn

    but not:

    Shawn
    Shawn
    Shawn

    Is this normal?

  9. #9
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: populating worksheet column from combobox

    So I tried what you sent, however I still can't successively pick the same name and have it show up in the next row in column header1? I can for instance pick "Shawn" then say pick "Ken O" then "Shawn" again:
    It is working correctly in the workbook uploaded in my last post. Did you try that workbook?

    Without seeing your actual workbook or all of the code and however you may have tried to adapt it, it's hard to say where the error is occuring.

  10. #10
    Registered User
    Join Date
    09-03-2009
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: populating worksheet column from combobox

    It is working correctly in the workbook uploaded in my last post. Did you try that workbook?
    Yes, I did upload it, and no it is not working, at least not the way I assume it should - it does the same thing mine does. I even tried removing all the names with the exception of one. I would expect that you could keep selecting that name and it would fill each successive row in that column with that name but it does not?

  11. #11
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: populating worksheet column from combobox

    I would expect that you could keep selecting that name and it would fill each successive row in that column with that name but it does not?
    OK. It seems to have finally sunk-in.

    Add this line of code at the end of the click event and it will "reset" the list and allow you pick any item as many times as you want.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    09-03-2009
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: populating worksheet column from combobox

    Thankyou Thankyou Thankyou!!!!, I new there had to be something that would allow this to work.

    Chris

  13. #13
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: populating worksheet column from combobox

    Glad to have been of help.

    If you're satisfied with the solution please mark your thread as solved and remember to add to the reputation of those who contributed.


    How to mark your thread solved


    How to add to a users reputation

+ 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