+ Reply to Thread
Results 1 to 11 of 11

E-mailing Sorted data to various people

  1. #1
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    E-mailing Sorted data to various people

    Hi,
    I have a table of 213 rows (with may change in the future)

    Every row needs to be grouped together depending on a value in column G. (Which I can do using the Sort function)

    However, the problem is, once the grouping is done, I then need to e-mail the data to various people using outlook.

    For example
    IF Column G = A (e-mail to Paul); IF Column G =B (e-mail to Gemma) etc.

    There can be over 100 different types of values in Column G, so I guess I would need to use a v-look up table. But I don’t have much experience with V-look up and I am not too sure how I can make it so that only each value gets e-mailed to the right person.
    I also can’t let person who gets value A information get value B information either.

    If anyone could help me, it would be very much appreciated
    I hope I have explained this ok, but if you need me to explain further let me know, I can also attached a copy of the spreadsheet if needed.
    Thanks in advance
    Rob

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: E-mailing Sorted data to various people

    You could try something like this:
    Please Login or Register  to view this content.
    If you wanted to use a lookup table then change the if statements to:
    Please Login or Register  to view this content.
    Where H1:I25 is your lookup range, with column H containing the possible values of column G and column I containing the matching email addresses.

    It's not clear exactly what information you want to send to each person so this is based on sending whatever is in column A. you need to change the .body to whatever it should actually be.

  3. #3
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Re: E-mailing Sorted data to various people

    Hi yudlugar,

    First of all thank you very much for the very quick response.
    I have been trying the different ways and the one using a look up would suit my needs the best, however, I am having a little trouble with it.
    When I run it I get "Unable to Get the Vlookup property of the WorksheetFunction class" at the " Mail_Address = WorksheetFunction.VLookup(Range("G" & count), Range("Email"), 2)" and it can't continue on, I have tried changing the vlook up range, but still I get the error.
    Any ideas on what I am doing wrong? The code is below

    Thanks
    Rob

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: E-mailing Sorted data to various people

    There is nothing wrong with how you are using vlookup in the code so the problem is in the data you are using the lookup on. There could be a few reasons that error could be brought up:

    -Range("G" & count) does not exist in Range("Email")
    -Range("Email") has only one column
    -Range("G" & count) is not in the first column of Range("Email")

    First thing to try is to put the vlookup on the worksheet and check that you get an answer. If you upload a worksheet with some sample data that still gives you the error I can take a look.

  5. #5
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Re: E-mailing Sorted data to various people

    Ok, thanks I changed it slightly to include column G,

    Please Login or Register  to view this content.
    But when it makes the e-mail it doesn't put the e-mail address in (the subject works ok) and the body text is only cell A1.

    I know I didn't make it clear in my first e-mail but I would like all rows (column A to F) with e.g. "775" in column G to be sent in the body text.
    then in a seperate mail all rows (column A to F) with e.g. "789" in column G to be sent in the body text.

    I have attached a file of how it look at the moment incase I am not explaining my self very clearly

    Email.jpg

    And a file of an exapmle of the information that I would like to send "[email protected] in another file (rows with "775" in column G)

    email after sort.jpg

    Thanks for all your help
    Rob

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: E-mailing Sorted data to various people

    Are you using IMail_Address in your code for the vlookup and Mail_Address when assinging the email to the .to property? That will be causing a problem.

    Also, you don't increment the count in your code (you need something like count = count+1 at the end of the loop) so it will presumably get stuck in an endless loop.

    As I mentioned in post 2 you need to change .body to be what you actually want to send. To send columns A to F it would be something like:
    Please Login or Register  to view this content.
    To send all rows with a specific value in a single e-mail you will need to change the structure of your loop. As you move down column G the process would be:
    -Find if value has already been sent (check values in rows above)
    -If it is first occurance, loop through to bottom row to find all the other rows with same column G value

  7. #7
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Re: E-mailing Sorted data to various people

    Hi yudlugar,

    I must have made a mistake when copying the script as I did mean to have IMail in the code.

    I have been trying to figure this out, but I seem to get a bit stuck.

    If you wouldn't mind I have attached a worksheet with some sample data in it. I just can't get it to work.

    Thanks
    Rob
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: E-mailing Sorted data to various people

    You need:
    Please Login or Register  to view this content.
    That will get the correct e-mail adresses in your sample. You were looking at columns G to I in your code whereas the lookup table was only in H and I.

    I don't know how to get the body as you want it.

  9. #9
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Re: E-mailing Sorted data to various people

    Wow Yudlugar,

    That is great thank you very much.

    The body text is causing me a problem is though.
    I needed the data to be filtered by the figure in column G
    Some examples would be:
    Any row with 775 in it, would be e-mailed to [email protected]
    Any row with 789 in it, would be e-mailed to [email protected]
    Any row with 803 in it, would be e-mailed to [email protected]
    and so no for all numbers in column G
    I have attached a spreadsheet for example of how they would be filtered, and also an e-mail example of how it could look.

    Sorry for not being clear in the first place.
    And thank you so much for your time and help with this
    Rob
    E-mail example.jpg
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: E-mailing Sorted data to various people

    I understood what you wanted, I just don't know how to do it.
    Try looking here:
    http://www.rondebruin.nl/mail/folder3/mail4.htm

  11. #11
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Re: E-mailing Sorted data to various people

    Ah ok.

    Thank you so much for your help and the quick response everytime:-)

    Rob

+ 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