Results 1 to 2 of 2

Thread: Modification in the Excel to Outlook mail

  1. #1
    Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    13

    Modification in the Excel to Outlook mail

    Hi All,

    I am using the attached macro to send excel sheet thru outlook mail body and am facing problem when the sheet is not exist.

    In the attached macro "Sheet 9" send to Mr.SSS(efgh@gmail.com) is not available but it is pasting the previously copied "Sheet1" instead of not coping(should be blank).

    Kindly help to modify if the sheet is not exist it should not copy anything.

    Regards,

    Prabhu
    Attached Files Attached Files

  2. #2
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    13
    In your code there are two email sending code first one is for Sheet1 or Sheet2 and second is for Sheet9 or Sheet2 so what email sending code you want me to check.

    Or check this one and add red colred syntax:

    Code:
    Set rng = Nothing
    Set rng2 = Nothing
    On Error Resume Next
    
    
    
    
    
    
        With Sheets("Sheet9")
            LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious).Row
            LC = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, _
                    SearchDirection:=xlPrevious).Column
            Set rng = .Range(.Cells(3, 1), .Cells(LR, LC)).SpecialCells(xlCellTypeVisible)
        End With
        
        
        With Sheets("Sheet2")
            LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious).Row
            LC = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, _
                    SearchDirection:=xlPrevious).Column
            Set rng2 = .Range(.Cells(3, 1), .Cells(LR, LC)).SpecialCells(xlCellTypeVisible)
        End With
    Last edited by LalitPandey87; 06-26-2014 at 11:50 AM.

Similar Threads

  1. Replies: 12
    Last Post: 12-10-2019, 09:56 PM
  2. Replies: 1
    Last Post: 12-23-2013, 10:09 PM
  3. Send E-mail using Other account by outlook.
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 0
    Last Post: 09-29-2013, 09:52 AM
  4. Automatically send Birthday E-Mail in Outlook
    By s.ajay88 in forum Outlook Help
    Replies: 2
    Last Post: 03-12-2013, 06:28 PM
  5. Outlook Send Mail With Multiple Recipient and CC
    By noobtron in forum Excel Help
    Replies: 2
    Last Post: 10-31-2012, 07:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •