+ Reply to Thread
Results 1 to 6 of 6

Combine 2 RonDeBruin macros - Mail+Attachment+Body - Based on value in A Column

  1. #1
    Registered User
    Join Date
    01-21-2013
    Location
    Goteborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Combine 2 RonDeBruin macros - Mail+Attachment+Body - Based on value in A Column

    Hi there, I've been struggeling with these codes for a while.
    I've searched the net, but I can't find any example which does what I need.

    Question:
    I need a macro that;

    Based on value in column A;

    1. Macro will find the "TO" E-mail address in Column B (Sheet1),
    2. Macro will create 1 mail per new value in A column
    3. Macro will find hyperlink to attachment in column C (Sheet1) and attach to e-mail
    4. Macro will copy the html body range from another sheet (X)

    What I have

    Based on value in column A;

    1. Macro will find the "TO" E-mail address in Column B (Sheet1),
    2. Macro will create 1 mail per new value in A column
    3. Macro will find hyperlink to attachment in column C (Sheet1) and attach to e-mail
    4. But it takes the same BODY to all the different E-mails.


    My code;

    Please Login or Register  to view this content.
    In other words, I'm very close - My code creates each mail, and have the correct attachment - but the body is the same in all the different E-mails.
    What am I doing wrong? I guess I've overworked the if rules at somehow - and would really appreaciate your assistance.

    Any help - changes to current code / new code is highly appreciated since I'm currently stuck..

    Thanks in advance

    // Joakim
    Attached Files Attached Files
    Last edited by J0ck3; 06-04-2013 at 09:23 AM. Reason: Adding Attachment!

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

    Re: Combine 2 RonDeBruin macros - Mail+Attachment+Body - Based on value in A Column

    I'm not sure, it would be easier to determine if you could attach a workbook but I would suggest trying this:
    Please Login or Register  to view this content.
    I've changed the arguement when you call the function from Rngx to Rng, you don't appear to define anything for Rngx before that point...

  3. #3
    Registered User
    Join Date
    01-21-2013
    Location
    Goteborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Combine 2 RonDeBruin macros - Mail+Attachment+Body - Based on value in A Column

    Hi, thanks for helping.
    that's true - actually I tried to define each range as RngX earlier - but then it did only copy the last range no matter what I tried.
    No I tried to go aroung with different ranges for each value, but I dont know how make the macro understand when to create the html copy for each range...

    Anyhow - I've attached a sample file to my inital post.

    thanks again

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

    Re: Combine 2 RonDeBruin macros - Mail+Attachment+Body - Based on value in A Column

    Try this:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-21-2013
    Location
    Goteborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Combine 2 RonDeBruin macros - Mail+Attachment+Body - Based on value in A Column

    Works like a charm!
    Super many thanks..

    I can see that you entered (cell) under my .Body statement,
    and (rngx) under the function name.

    Are you able to explain me the meaning here?
    That RNGX will take information from "cell" as standard value, and that rngx will be the startpint from where the function search for my values?

    Anyhow - many thanks!
    // Joakim

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

    Re: Combine 2 RonDeBruin macros - Mail+Attachment+Body - Based on value in A Column

    Yeah basically, you can pass a variable from one macro to the other by defining it with:
    Please Login or Register  to view this content.
    and then when you call the macro, you can assign either a variable from the existing macro to it:
    Please Login or Register  to view this content.
    so when I use that to call macro_1, variable_1 has the value thisisastring and variable_2 has the value 1.

    I made some other changes as well, mainly to the rangetohtml macro.

+ 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