+ Reply to Thread
Results 1 to 10 of 10

Auto sending email from Excel

  1. #1
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Auto sending email from Excel

    Good day!
    I have some code which created an email with data taken from excel. The only problem is, it doesn't seem to keep all the formatting. Dates are numbers, left align moves to right align etc.
    Can anyone suggest how i can fix this please?

    Please Login or Register  to view this content.
    It would also be useful to find the last row with a value (not just a formula that returns "") instead of 'Set SendingRng = ActiveWorkbook.Sheets("Summary").Range("A1:B400")'. Something like .Range("A1:B" & Last Cell), except something that works!

    Best wishes
    Jimmi
    Last edited by jimmisavage; 02-20-2020 at 05:27 AM.

  2. #2
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Auto sending email from Excel

    To follow up my post - it looks like this got a bit more complicated. My formatting is a conditional format - so i want to copy the conditional formatting without copying the rules into the email.
    I don't know if this is possible but maybe there is a way to copy the data and conditional formatting without copying the rules into another sheet? Then I can use that sheet as the email range?

    I am completely stumped on this! Using Excel 2010.

    Any help is appreciated.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Auto sending email from Excel

    1.) edit your original thread and obfuscate the actual TO: email address

    2.) Set SendingRng = Sheets("Summary").Range("A1", Sheets("Summary").Range("B" & Rows.Count).End(xlUP))

    3.) The code would have to copy the sheet and apply the actual formatting to each cell the same as the conditional formatting rules do.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Auto sending email from Excel

    Quote Originally Posted by AlphaFrog View Post
    1.) edit your original thread and obfuscate the actual TO: email address

    2.) Set SendingRng = Sheets("Summary").Range("A1", Sheets("Summary").Range("B" & Rows.Count).End(xlUP))

    3.) The code would have to copy the sheet and apply the actual formatting to each cell the same as the conditional formatting rules do.
    Hi AlphaFrog,
    Thanks for the reply. I have amended my original post - thanks for pointing that out.

    2: No matter what code I put in it always seems to think row 400 is my last cell. There is an {INDEX} formula in the cells, which is probably why, but is there a way around that? I guess I need to find the last cell that has an actual value that isn't #NUM! or #N/A?

    3. The formatting issue is a real stumbling block from what i have found online because its formatted almost entirely on conditional formatting (each cell changes and the results need different formatting). To overcome this, i think i'm going to try and save/email the sheet as a pdf. That way it will be sent exactly as it's seen in the spreadsheet.

  5. #5
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Auto sending email from Excel

    For point number 2. Last row excluding formulas try
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Auto sending email from Excel

    Hi Nigel,
    Thanks for your input. This seems to work well for a copy/paste job (as I needed in my first post) but I can't seem to make it work for my pdf alternative. I'm searching the range - how would i use that code in here?
    The range should be A1:B last used row

    Please Login or Register  to view this content.
    Thanks again
    Jimmi

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Auto sending email from Excel

    ActiveWorkbook.Sheets("Summary").Range("A1:B" & lr).ExportAsFixedFormat ...

  8. #8
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Auto sending email from Excel

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Auto sending email from Excel

    Thank you Nigel and Alpha for all the help. I have achieved what I needed to achieve now
    I hope you both have a great day!

  10. #10
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Auto sending email from Excel

    Glad you got it sorted. Many thanks for the rep points

+ 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. Auto-select correct sending account when replying to a forwarded email?
    By twilsonco in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 12-17-2016, 01:32 AM
  2. Replies: 0
    Last Post: 11-24-2015, 03:29 AM
  3. Auto sending email reminders to clients from excel
    By HGV in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2014, 11:33 AM
  4. Replies: 2
    Last Post: 09-22-2012, 01:18 PM
  5. Auto email generation and sending through outlook before one month of contract end da
    By kumar_shri in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2011, 06:18 AM
  6. auto sending email before due date via excel 2003
    By AsifShabbir in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 03-02-2011, 09:00 AM
  7. auto tracker function and sending of personalised email from outlook 2000(Urgently)
    By xiaotianshi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2007, 09:11 AM

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