Results 1 to 6 of 6

Thread: How Get Value From A Cell Range Using VBA

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    9
    Rep Power
    0

    How Get Value From A Cell Range Using VBA

    Guys,

    I already have the code I want, but it's late and I'm struggling to put the icing on the cake (as it were).

    I have managed to customise the entire thing, but am struggling to get VBA to identify a cell from which to get the email address for the 'To:' line in the email...

    Code:
     'Create a temporary file in your current directory that uses the name
        ' of the sheet as the filename
        LFileName = LWorkbook.Worksheets(1).Name
        On Error Resume Next
        'Delete the file if it already exists
        Kill LFileName
        On Error GoTo 0
        'Save temporary file
        LWorkbook.SaveAs Filename:=LFileName
    
        'Create an Outlook object and new mail message
        Set oApp = CreateObject("Outlook.Application")
        Set oMail = oApp.CreateItem(0)
        
        'Set mail attributes (uncomment lines to enter attributes)
        ' In this example, only the attachment is being added to the mail message
        With oMail
            .To = G10.Value
            .CC = "Jill.X@MAIL.COM' Alexander.C@MAIL.COM"
            .Subject = "Opposition to your Change Paper - Comments Attached"
            .body = "Dear Sponsor," & vbCrLf & vbCrLf & _
                    "I have reviewed your proposed Change and am unable to support it at the present time." & vbCrLf & vbCrLf & _
                    "Please see attached for my comments." & vbCrLf & vbCrLf & _
                    "Kind regards,"
            .Attachments.Add LWorkbook.FullName
            .Display
        End With
    So, your comments are very welcome - all I need is to tell the macro to look in G10 of the sheet it's attaching to find the recipient's email address... argh!

    Please help!

    Kind regards,

    Alex


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 10-02-2023 at 12:50 PM.

Similar Threads

  1. ONE CELL AS RANGE IN VBA INSIDE AN IF STATEMENT
    By jffryjsphbyn in forum Excel Help
    Replies: 1
    Last Post: 07-16-2013, 09:49 PM
  2. Replies: 8
    Last Post: 04-29-2013, 08:36 PM
  3. Lookup From Cell Range By Matching Row and Column
    By paul_pearson in forum Excel Help
    Replies: 2
    Last Post: 03-07-2013, 02:02 PM
  4. Replies: 4
    Last Post: 02-22-2013, 02:24 AM
  5. Get last Filled Cell address in a Range.
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 3
    Last Post: 03-24-2012, 01:08 AM

Posting Permissions

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