+ Reply to Thread
Results 1 to 4 of 4

Loop Through All Sheets and Combine Into One Email with Conditions

  1. #1
    Registered User
    Join Date
    12-06-2019
    Location
    us
    MS-Off Ver
    office 365
    Posts
    18

    Exclamation Loop Through All Sheets and Combine Into One Email with Conditions

    Hello, so I have a dynamic number of sheets and I would like to loop through all of it then combine the data in all of the sheets into one email.
    The condition is, if cell A1 of the sheets is blank, it will copy everything in that sheet. But if cell A1 of the sheets is not blank, it will only copy cell B2, put two blank lines below and then copy the data in cell E10 of my Email Sheet.

    Here's my code. This only does the last sheet. (attached sample workbook. I could not post the thread getting an error about HTML codes)



    The code enclosed in '>>>>>>>>>>>>>>>>> is the part I am having troubles with. Please help. I appreciate all the help I will get. Thank you
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    12-06-2019
    Location
    us
    MS-Off Ver
    office 365
    Posts
    18

    Re: Loop Through All Sheets and Combine Into One Email with Conditions

    Anyone?

  3. #3
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Loop Through All Sheets and Combine Into One Email with Conditions

    Try using & vbNewLine & instead of & "<Br>" &

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Loop Through All Sheets and Combine Into One Email with Conditions

    I gave it go and have only been able to produce four individual outlook emails, instead of a combined one you request. for whatever reason, one can't use a for loop inside the mail object. Your code does create the four emails, they just write one over the other. The only way I can envision solving this riddle, is to create a spreadsheet of the combined sheets and then load them with the RangetoHTML function. For the record, your code is clean and should by all appearance work as written. Maybe a guru can jump in here and resolve this further. Here is my version of the code.

    Please Login or Register  to view this content.
    Note, i reversed the original code to use only one version of RangetoHTML() instead of the multiples you had. That change was a good idea but it didn't appear to make a difference. My changes are in Module 1. For future reference, the items with < and > are considered html and are not allowed via this Excel Forum page display.
    Last edited by maniacb; 07-25-2020 at 07:30 AM.

+ 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. [SOLVED] Loop through all sheets & if cell is blank then send email
    By Jamesraywebber85 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-02-2019, 04:37 PM
  2. Help make my code work: Loop through folder of workbooks with multiple sheets and combine
    By carlito2002wgn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-06-2019, 08:19 PM
  3. [SOLVED] Combine 2 Columns from 2 different sheets with 2 conditions
    By Sekars in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-23-2017, 09:34 AM
  4. [SOLVED] Sending an email on conditions met in a loop
    By cgoan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2015, 07:42 AM
  5. PRETTY PLEASE. VBA to Loop to combine sheets and print out
    By ceoleo23 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2014, 12:24 AM
  6. VBA code to loop through 3 columns, chk for 2 conditions and email txt from the cells
    By philipcph in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 01:14 AM
  7. Combine data from multiple sheets with conditions
    By luckyk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-28-2012, 11:20 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