+ Reply to Thread
Results 1 to 8 of 8

Custom function to return username part of outlook emails

  1. #1
    Registered User
    Join Date
    04-27-2022
    Location
    New York, USA
    MS-Off Ver
    Office 365 Apps for Enterprise
    Posts
    9

    Question Custom function to return username part of outlook emails

    This is part of a bigger project I'm working on to help automate finding the first & last names of users in my Outlook global address book. I found and attempted to follow an article for retrieving Outlook address book data from Excel using a custom function to pull the username and return First Name, Last Name, etc.

    But that code seems to assume that the cell value is already just the alias/username. So I have 145 cells of full email addresses I need to pull the usernames from, then attempt to use the code I found in that article to pull the Outlook information.

    I'd paste screenshots, but apparently I can't because I'm still new (also it keeps flagging the example email as a link argh), so here's a small example what I need it to do, starting with only the full email.

    Full Email Username First Name Last Name
    usrnme1[at]email-dot-com usrnme1 User1 Name1
    usrnme2[at]email-dot-com usrnme2 User2 Name2
    usrnme3[at]email-dot-com usrnme3 User3 Name3
    usrnme4[at]email-dot-com usrnme4 User4 Name4
    usrnme5[at]email-dot-com usrnme5 User5 Name5
    usrnme6[at]email-dot-com usrnme6 User6 Name6
    usrnme7[at]email-dot-com usrnme7 User7 Name7
    usrnme8[at]email-dot-com usrnme8 User8 Name8
    usrnme9at]email-dot-com usrnme9 User9 Name9


    FOR CONTEXT:
    I'm having to subtract the last "[at]email-dot-com" part because the first half "usrnme" part is not the same amount of characters across all of the emails (unfortunately).

    THE ACTUAL QUESTION:
    I'm not sure what I'm doing wrong in being able to call the function in the B2 cell to make the cell value just that "usrme" part that it pulls from A2 and so forth. I'm trying to test it solo so I know it works before merging it with the other part I found.

    I'm pretty sure I could do this, especially the last "calling it" part, by defining a range and everything...? But I feel that limits the potential of this. If it's possible I'd like to use this across multiple workbooks in the future, in the same way. Either being able to run it in individual cells (which does seem still sort of tedious), or running it as its own macro across entire Worksheets/Workbooks.

    EXCEL VERSION:
    I'm using Excel as part of Office 365 Apps for Enterprise, Ver 2206, on Windows 10 as the desktop app. Example book should be attached.
    Attached Files Attached Files
    Last edited by Faru298; 07-12-2022 at 11:59 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Custom function to return username part of outlook emails

    Maybe:

    =LEFT(A2,SEARCH("@",A2)-1)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    04-27-2022
    Location
    New York, USA
    MS-Off Ver
    Office 365 Apps for Enterprise
    Posts
    9

    Re: Custom function to return username part of outlook emails

    RE: Glenn Kennedy

    Thank you, but it has to be relative to the cell it's being pasted into, i.e A2 isn't the only cell I need this function to work with.

    More like; Function to parse entire column A for full email > somehow only take the usrnme part out > paste that usrnme into the cell to the right (Column B) of that cell that it got the full email from, so it all matches correctly.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Custom function to return username part of outlook emails

    Hi there.

    You provided a one-row sample. If you want something differnet to happen in multi-row samples... then provide a multi-row sample.

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 non-editable pictures.

    Please read the yellow banner about sample worksheets, at the top of the screen. Act on its guidelines and post a SMALL sample sheet complete with an explanation and some expected results.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,480

    Re: Custom function to return username part of outlook emails

    Drag copy Glenn's formula down.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    04-27-2022
    Location
    New York, USA
    MS-Off Ver
    Office 365 Apps for Enterprise
    Posts
    9

    Re: Custom function to return username part of outlook emails

    I've edited my original post to include more rows, and I reuploaded the workbook with more rows. I did mention in my original post as well that my actual workbook contains 145 emails.... I can't post the actual one I'm working on because it contains real people's emails and is therefore sensitive information, so I hope the new information helps, thank you.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,480

    Re: Custom function to return username part of outlook emails

    In B2 copied down:

    =LEFT(A2,FIND("@",A2)-1)
    Attached Files Attached Files

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Custom function to return username part of outlook emails

    Ali was correct. Just drag my formula down.
    Attached Files Attached Files

+ 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. Replies: 5
    Last Post: 09-22-2020, 10:57 AM
  2. Send emails in Outlook with custom PDF attachment using Excel and word
    By malek_ali7sas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2020, 08:08 AM
  3. [SOLVED] Macro to Draft Outlook Emails and Attach files in Emails
    By arun.sj in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-17-2020, 05:48 AM
  4. Function to return and input an email address from username/details?
    By ZEROCOOL UK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2019, 11:28 AM
  5. Add Checkboxes that will return emails addresses in the BCC field into Outlook
    By j7house in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2017, 02:09 AM
  6. [SOLVED] Sending Outlook emails from Excel; Limits to three emails only?
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2013, 06:53 AM
  7. Send outlook emails with message in cells to individual emails associated with them
    By abinayan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2011, 06:11 AM

Tags for this Thread

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