Results 1 to 5 of 5
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Linking Name in Code to cell address

    I have the following code below, which I want to link to a cell so that the name for e,g. Peter it can be changed in the cell as opposed to within the code


    Code:
     StrBody:="<H3><R>Dear Peter</R></H3><br>" & _
                                              "<body>Attached please find Management Report for Br1" & _
                                              "<br><br>" & "Regards</body>"


    I know that need to declare a variable for e.g.

    Dim StrBody as String

    StrCCAddr = Range("M3").Value (have the name in Cell M3 for eg Peter)



    It would be appreciated if someone could assist me in amending my code so that if I change my name on my sheet, that this will link to the name within StrBody:=

    I also need the name not to be in Bold

    Your assistance in resolving this is most appreciated
    Last edited by HowardC; 2015-04-27 at 02:15.

  2. #2
    Lounger
    Join Date
    Feb 2011
    Posts
    28
    Thanks
    0
    Thanked 10 Times in 8 Posts
    I'd use something like:

    StrBody:="Dear " & StrCCAddr & "<br>" & _
    "<body>Attached please find Management Report for Br1" & _
    "<br><br>" & "Regards</body>"

    Using the H3 tag creates bold text so omitting it stops the text being bold. If you want a larger text size, use a bit of CSS in the tag, e.g:

    <p style=font-size:2em>Dear Peter</p>Attached please find Management Report for Br1 etc.

  3. #3
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    Thanks for your help

    I have amended as follows:

    Code:
     Dim StrBodyAddr As String
    
    StrBodyAddr = Range("M3").Value
    
    
    StrBody:="Dear " & StrBodyAddr & vbNewLine & vbNewLine & _
                                                           "<body>Attached please find Management Report for Br1" & _
                                              "<br><br>" & "Regards</body>"

    I Have tried to have to lines of spacing on my email after Dear for eg

    Dear Peter

    Attached please find Management Report for Br1

    It curremntly looks like

    Dear Peter
    Attached please find Management Report for Br1

    Regards

    I have tried to get this to work but am battling

    It would be appreciated if you could assist

  4. #4
    Lounger
    Join Date
    Feb 2011
    Posts
    28
    Thanks
    0
    Thanked 10 Times in 8 Posts
    Try using the <p> tag instead:

    Code:
    StrBody:="<body><p>Dear " & StrCCAddr & _
    	"</p><p></p>Attached please find Management Report for Br1" & _
    	"<br><br>" & "Regards</body>"

  5. #5
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    Thanks very much. Code works perfectly

Posting Permissions

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