+ Reply to Thread
Results 1 to 28 of 28

Vlookup table to find email addresses

  1. #1
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Vlookup table to find email addresses

    I have a table (tblEmails) on a worksheet, It has two columns. First column named Subcontractors and second named email.

    I have created a userform with two listboxes (lboSubcontractors) and (lboEmails). I want the code to find the email addresses for all the subcontractors in the listbox and show them in the second listbox.

    I am not sure how to go about this but I would say a loop to vlookup each name in the listbox?

    I'd really appreciate any help with this!

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Vlookup table to find email addresses

    How are you populating the Subcontractors listbox? Is it all the values in the table or just some?

  3. #3
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    There is over 100 company names in the table and only some will be selected each time. The subcontractors listbox names will be identical to the names in the table. I just need it to return the email address for each name in the listbox

    Thanks

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Vlookup table to find email addresses

    Can you post the code that loads the listbox?

  5. #5
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    Please Login or Register  to view this content.
    I have a table on my worksheet that has the email addresses for each of them company's. But can you vlookup the table with each company as the reference and return their emails in another listbox?

    Thanks

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Vlookup table to find email addresses

    Ok, thanks for that.
    How about
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    sorry, I should've mentioned that is only one way it will be populated. I have 40 checkboxes and depending on which one is checked determines the subcontractors (array) that populates the listbox. So each time a checkbox is checked the listbox will be updated with new names which is why I was thinking of using vlookup type thing.

    Thanks for your help btw

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Vlookup table to find email addresses

    Assuming that code is run on a checkbox_Click event, you could use the same structure for each chkbox.

  9. #9
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    does that mean I need to do that code 40 times?. The checkboxes will work on a click event to update the subcontractors listbox but the email listbox will work off a listbox click event if that makes sense? Sorry I'm quite new to vba so thanks for your time

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Vlookup table to find email addresses

    I can see this going around in circles...
    Colin, why not just upload a sample file depicting your actual scenario...This way, the best possible solution can be offered...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  11. #11
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    Hi Sintek,

    Yes sorry I originally should've posted my file to make it clearer but I do not have access to my work computer atm to get the file.

    I used @ Fluff13 code and made a few name changes to suit and it seems to work perfectly!

    Could you or fluff13 have a quick look at the code to see if this is the correct and the most efficient way and do I just repeat this code 40 times for the 40 different scenarios?

    Thank you for your help!

    Please Login or Register  to view this content.
    Last edited by colin7; 09-21-2019 at 04:37 AM.

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Vlookup table to find email addresses

    do I just repeat this code 40 times for the 40 different scenarios?
    No, that is madness...

    I assume this is the name of one of the checkboxes...lboEmailTrades
    I personally do not rename controls for this specific reason...So much easier identifying controls with there original name esp for looping purposes...
    One could make use of one code and dependent upon which checkbox gets clicked, run the code...


    EDIT

    There is over 100 company names in the table and only some will be selected each time
    How do you select these...
    Last edited by sintek; 09-21-2019 at 05:02 AM.

  13. #13
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Vlookup table to find email addresses

    I have 40 checkboxes and depending on which one is checked determines the subcontractors (array) that populates the listbox
    I would use Option buttons
    This is what I have in mind...
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    My process is I have 40nr Checkboxes for each type of trade on a userform ie Scaffolding Glass Stone Metal etc. A user will click the checkboxes for each type of trade required for that job.

    If selected a listbox for that trade will get populated with the relevant company names. In my code this listbox is named lboBuilderswork. using code (If ckboxBuilderswork.Value = True Then lboBuilderswork.List = Array("Trade1", "Trade2", "Trade3")

    The lboEmailTrades listbox gets populated with a list of all the trades selected when clicking the checkboxes. So from there Fluff13's code works perfect but I will need 40 different scenarios of it for the 40 trades;

    Please Login or Register  to view this content.
    I hope this makes a bit of sense, sorry I cant post my actually file atm

    Thanks

  15. #15
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Vlookup table to find email addresses

    So you have 40 snippets of code such as below...populating the listbox with each checkbox having a unique name...
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    Yes that's correct!

    I have 40 small listboxes for each trade as its an easy way to look at all the contacts selected
    Last edited by colin7; 09-21-2019 at 05:55 AM.

  17. #17
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Vlookup table to find email addresses

    So if lboBuilderswork is populated by via checkbox selection then just run code to loop through lboBuilderswork and update lboEmailList listbox
    calling the procedure in each checkbox selection...i.e

    Please Login or Register  to view this content.
    This is separate Module...
    Put this in Userform Initialize Event
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    EDIT...

    See you changed your post above...
    So you have 40 listboxes for SubContractor and 1 for email or 40 for email as well...
    Last edited by sintek; 09-21-2019 at 06:10 AM.

  18. #18
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    I edit the 40 listboxes sometimes to add more new contacts in or out depending on job location etc. so will that way still work?

  19. #19
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Vlookup table to find email addresses

    Fell into my own trap...Running around in circles....
    Not much we can do until actual sample file is attached...Till next time...

  20. #20
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    I will make up a quick sample File to try to show you what I mean

  21. #21
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    Please see attached sample file

    Thanks
    Attached Files Attached Files

  22. #22
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Vlookup table to find email addresses

    How about change the chkbox events to
    Please Login or Register  to view this content.
    and put this in the userform module
    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    fluff13 thanks very much for this.

    Few questions

    Would I need to repeat this code for all 40 checkbox click events?

    And my array is initially just to populate the listbox with my usual subcontractors, then I will use the lbobuilderswork listbox etc to add new subcontractors in depending on the job. Therefore array needs to equal the items in lbobuilderswork.

  24. #24
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Vlookup table to find email addresses

    Quote Originally Posted by colin7 View Post
    Would I need to repeat this code for all 40 checkbox click events?
    Yes you will, but only the first code, the second code remains as-is.

    When you add the extra subcontractors, you will need to modify the code to add the extra emails as well.

  25. #25
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    Thanks very much for your help, really appreciated.

    Would you know a way to modify the code to suit adding more in?

    Thank you

  26. #26
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Vlookup table to find email addresses

    You're welcome & thanks for the feedback.

    As your new request is totally different, you will need to start a new thread & include your existing code.

  27. #27
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: Vlookup table to find email addresses

    Returned home and noticed this still active.
    I see a number of your other queries have been answered.
    However if this is still ongoing my partial solution is attached.
    Adding to the list automatically expands the scope as there are no 'hard coded fields' to search.
    torachan.
    Attached Files Attached Files

  28. #28
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Vlookup table to find email addresses

    Hi torachan,

    Thanks for your reply!

    I think your code will work brilliantly. I will try to incorporate your code into my file and see how it goes, thank you

+ 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. Create vlookup tax table that addresses negative numbers
    By januerry in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-28-2014, 11:09 PM
  2. send parts of pivot table to different email addresses
    By meaganmg in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-02-2013, 06:40 PM
  3. Code to automatically add new email addresses to a table
    By Jetset123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-31-2013, 10:18 PM
  4. [SOLVED] clean email addresses (function mid, find, left, len)
    By FFlo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2012, 11:35 PM
  5. Find email addresses and Replace with blank
    By guru420 in forum Excel General
    Replies: 4
    Last Post: 09-21-2011, 04:27 AM
  6. Replies: 4
    Last Post: 02-07-2011, 09:32 AM
  7. [SOLVED] vlookup and email addresses
    By youth in forum Excel General
    Replies: 4
    Last Post: 10-25-2005, 02:05 AM

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