+ Reply to Thread
Results 1 to 13 of 13

UserForm ListBox Populated by Summed Data in Two Columns

  1. #1
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    UserForm ListBox Populated by Summed Data in Two Columns

    I have a worksheet with employees listed in Column A and their hours in Column B. I'd like to populate a 2-column userform ListBox with names from column A (minus duplicates), and then summing the values in column B using the names in the first column of the ListBox.

    Let me know if that doesn't make sense and I'll attach a sample worksheet.


    Thanks!!

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    A sample worksheet would help a lot.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Ok...I've attached a sample workbook.

    In my UserForm, the first column of the ListBox pulls the individual employees in Column A of Sheet1. What I'm trying to do is get each employee's total hours from Column B on Sheet1 in the second column of the ListBox.

    Also, I can't quite seem to get the headers on the ListBox to pick up the headers from row 1.
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Perhaps you could use a dictionary.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Norie, that works great!! Thanks so much!!

    Any idea how to get the ListBox headers to populate from the first row?

  6. #6
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Ok...so it works in the sample workbook, but it doesn't work when i move it to my actual workbook. I get Run-time error 70: Permission denied. Any idea why that would be?

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

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Because you've set a row source, you can't have a row source and use additem

  8. #8
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Kyle123, so what would you do instead?

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

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Norie's code

  10. #10
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    But Norie's code isn't working in my actual workbook. It gives me the permissions error

    Have I maybe set the row source somewhere else?

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

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Then remove the rowsource from the listbox...

  12. #12
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Ok...I see what you're saying. That fixed it. Thanks!!

    Now, how do I get the column headers to show up?

  13. #13
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: UserForm ListBox Populated by Summed Data in Two Columns

    Nevermind. I got it all figured out. Thanks for all your help.
    Last edited by phelbin; 10-05-2017 at 03:06 PM.

+ 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. Filter UserForm Multicolumn ListBox. populated by RowSource. with TextBox/ComboBox
    By Alex.riccio in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-07-2016, 10:19 AM
  2. [SOLVED] hide columns if they are empty populated from userform
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2014, 08:10 AM
  3. Transfer Data From One Userform Listbox to Another Userform Listbox with 11 columns
    By sparkoft in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-18-2013, 10:54 AM
  4. Complex userform with user-populated listbox
    By olivierpbeland in forum Excel Programming / VBA / Macros
    Replies: 72
    Last Post: 01-23-2013, 04:18 PM
  5. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  6. VBA Code to Search/Edit Data Populated by Userform
    By pjohnson9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2011, 04:25 PM
  7. Error in populated listbox userform
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2010, 09:54 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