+ Reply to Thread
Results 1 to 4 of 4

Create a Table within a For loop that gets placed into an E-mail Macro

  1. #1
    Registered User
    Join Date
    02-13-2015
    Location
    Seattle, WA
    MS-Off Ver
    2013 (Work) & 2016 (Home)
    Posts
    33

    Create a Table within a For loop that gets placed into an E-mail Macro

    Hello,

    So I've got a bit of a conundrum on my hands and am unsure if this is even possible. So I currently have a worksheet with a bunch of rows and columns and my macro is a For loop and based off of certain criteria, it pulls information from the worksheet and places it into an email to send to another party. Now, this party has a very specific way of wanting to view the data (in a tabular format), so they would like it to look like a standard table separated by borders (Excel Table Style Light 15 is close enough). The table would is 2 columns and 12 rows, with each row (except the last) based on values in the worksheet. So the output would look something like this:

    Capture.PNG

    Is there any possible way to do this? As always, any help is greatly appreciated
    Last edited by kujoking7; 11-20-2017 at 06:24 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,619

    Re: Create a Table within a For loop that gets placed into an E-mail Macro

    Yes, it is.
    It's a pitty, you have not shown code you use, because answer partially depends on ir.

    If you generate TXT type body of mail (your outmail.body) you shall change this to HTMLBody


    then somewhere in a body you shall have tags like
    Please Login or Register  to view this content.
    all tags have to be betwen "less than" and "greather than" characters, but as software of our forum do not like it I skipped them.
    and here your first value shall be concatenated with the rest of the body
    Sample of such approach is shown for instance here: https://stackoverflow.com/questions/...excel-contents note for instance how variable FinalRatioLCR is inserted into HTMLBody of OutMail (in your case not just variable, but your cell.columns(i).value)
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    02-13-2015
    Location
    Seattle, WA
    MS-Off Ver
    2013 (Work) & 2016 (Home)
    Posts
    33

    Re: Create a Table within a For loop that gets placed into an E-mail Macro

    Very interesting, I did not know you could crate a .HTMLBody as opposed to .Body within the email code. Thank you very much for your guidance, I will play around with the HTML code to eventually get the result I'm looking for.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Create a Table within a For loop that gets placed into an E-mail Macro

    .
    Please Login or Register  to view this content.
    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. Macro to create / add more than 30+ signatures in outlook e-mail
    By alexgoaga in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2017, 04:31 AM
  2. [SOLVED] VBA Loop Through Table to Create Charts
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2014, 07:10 AM
  3. [SOLVED] VBA Loop Through Table To Create Charts
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-19-2014, 01:57 AM
  4. Replies: 1
    Last Post: 07-23-2014, 04:33 AM
  5. [SOLVED] Loop extention in mail macro
    By Liz_Biz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-07-2014, 10:54 AM
  6. Macro does not loop through all mail merge letters correctly
    By Bpd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2014, 01:39 PM
  7. Macro to create an e-mail using an Outlook Template and add an attachment
    By hsarro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2012, 12:25 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