tabbing in line with table content

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hi i have the code below where i want the F6.value (located underneath the .HTMLBody and highlighted in BOLD)) to be directly underneath the 2nd of the Replans (highlighted in BOLD), i have tried the CHR and the VBR but they are not working, can you help please?

Code:
Private Sub CommandButton7_Click()

Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String

Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)

          aEmail.HTMLBody = "<html>******>" & _
                            "<p>Hi " & Worksheets("Northants").Range("A1").Value & "</p>" & _
                            "<p>" & Worksheets("Northants").Range("C6").Value & Chr(9) & Worksheets("Northants").Range[B]("F6").Value[/B] & "</p>" & _
                            "<table border=""1"", cellpadding=""10"", style=background:""#a6bbde"" >" & _
                "<tr>" & _
                            "<th>Replans:</th>" & "<td>" & Worksheets("Northants").Range("B8").Value & "</td>" & "[B]<th>Replans:</th>[/B]" & "<td>" & Worksheets("Northants").Range("F8").Value & "</td>" & _
                            "</tr>" & _
                "<tr>" & _
                            "<th>Timeband Slides:</th>" & "<td>" & Worksheets("Northants").Range("B9").Value & "</td>" & "<th>Timeband Extensions:</th>" & "<td>" & Worksheets("Northants").Range("F9").Value & "</td>" & _
                            "</tr>" & _
         "<tr>" & _
                            "<th>Jobs Unscheduled:</th>" & _
                            "<td>" & Worksheets("Northants").Range("B10").Value & "</td>" & _
                            "</tr>" & _
                            "</table>" & _
                "<br>" & _
                "<p>" & Me.TextBox2.Value & "</p>" & _
                "<p>" & Me.TextBox1.Value & "</p>" & _
                "<p>Many Thanks</p>" & _
                "<p>Northants and Bucks Jeopardy Manager</p>" & _
                "</body></html>"


        aEmail.Recipients.Add (Worksheets("Northants").Range("C6").Value)
        aEmail.CC = (Worksheets("Northants").Range("C6").Value)
        aEmail.BCC = ""
        aEmail.Subject = "Weekly " & Range("D1").Value
        aEmail.Display
        
   
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
If you are using HTMLBody the you should use HTML to compose your message.

For one thing all the white space you've added will be ignored as will any special characters you use.

Do you actually want to have a table in the body of the email and populate it with values from a worksheet?
 
Upvote 0
hi sorry i am new to this and really confused what you mean? i have re copied the code below in html if that helps with my query

HTML:
Private Sub CommandButton7_Click()

Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String

Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)

          aEmail.HTMLBody = "<html>******>" & _
                            "<p>Hi " & Worksheets("Northants").Range("A1").Value & "</p>" & _
                            "<p>" & Worksheets("Northants").Range("C6").Value & Chr(9) & Worksheets("Northants").Range("F6").Value & "</p>" & _
                            "<table border=""1"", cellpadding=""10"", style=background:""#a6bbde"" >" & _
                "<tr>" & _
                            "<th>Replans:</th>" & "<td>" & Worksheets("Northants").Range("B8").Value & "</td>" & "<th>Replans:</th>" & "<td>" & Worksheets("Northants").Range("F8").Value & "</td>" & _
                            "</tr>" & _
                "<tr>" & _
                            "<th>Timeband Slides:</th>" & "<td>" & Worksheets("Northants").Range("B9").Value & "</td>" & "<th>Timeband Extensions:</th>" & "<td>" & Worksheets("Northants").Range("F9").Value & "</td>" & _
                            "</tr>" & _
         "<tr>" & _
                            "<th>Jobs Unscheduled:</th>" & _
                            "<td>" & Worksheets("Northants").Range("B10").Value & "</td>" & _
                            "</tr>" & _
                            "</table>" & _
                "<br>" & _
                "<p>" & Me.TextBox4.Value & "</p>" & _
                "<p>" & Me.TextBox2.Value & "</p>" & _
                "<p>" & Me.TextBox5.Value & "</p>" & _
                "<p>" & Me.TextBox1.Value & "</p>" & _
                "<p>" & Me.TextBox6.Value & "</p>" & _
                "<p>" & Me.TextBox3.Value & "</p>" & _
                "<p>Many Thanks</p>" & _
                "<p>Northants and Bucks Jeopardy Manager</p>" & _
                "</body></html>"


        aEmail.Recipients.Add (Worksheets("Northants").Range("C6").Value)
        aEmail.CC = (Worksheets("Northants").Range("C6").Value)
        aEmail.BCC = ""
        aEmail.Subject = "Weekly " & Range("D1").Value
        aEmail.Display
        
   
End Sub
 
Upvote 0
It looks like you are doing what I was suggesting, using HTML code to compose the body of your email.

Is it not working out as you want?
 
Upvote 0
it sis doing what i want apart from one little bit where i want cell F6 to be inline with F8 if you can help please :)
 
Upvote 0
Why not add a small borderless table above the table you already have and populate it with the values from C6 and F6?
 
Upvote 0
okay thatnk you for your help i have managed to work around it by adding a line to break it up.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top