Unable to return the range but only the word "true"

vbalearner721

New Member
Joined
Apr 27, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Here below is the code to create a draft email from excel, the current region is correctly selected but it doesn't show in email body correctly, it only shows a word "True", please see attached 2 pics.

Please help as I have googled for days and cannot sort out the problem, thank you so much.


Dim myDataRng As Range
Set myDataRng = Range("c2:c2")

Dim hk As String
hk = Range("B11").CurrentRegion.Select


For Each Cell In myDataRng

If Cell.Value > 0 Then

Dim objOutlook As Object
Set objOutlook = CreateObject("outlook.application")

Dim objEmail As Object
Set objEmail = objOutlook.CreateItem(olMailItem)

Range("K2").Select

With objEmail
.SentOnBehalfOfName = "shipping@therange.co.uk"
.to = ActiveCell.Offset(0, 1).Value
.Subject = ActiveCell.Offset(7, 0).Value
.htmlbody = "Supplier Code " & " " & Cell.Offset(0, 0).Value & "<br>" & _
"Supplier Name: " & " " & Cell.Offset(1, 0).Value & "<br>" & _
"Currency " & " " & Cell.Offset(2, 0).Value & "<br>" & "<br>" & "Dear Supplier," & "<br>" & "<br>" & _
"A payment has been issued to you, as detailed below. " & "<br>" & _
hk & "<br>" & "<br>"
.Save
End With
 

Attachments

  • Screenshot 2022-04-29 120847.jpg
    Screenshot 2022-04-29 120847.jpg
    5.2 KB · Views: 13
  • excel.jpg
    excel.jpg
    42.3 KB · Views: 12

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I am afraid there is a bit more to it than that.
1) You will need to
VBA Code:
Dim hk as range
Set hk = Range("B11").CurrentRegion
2) Copy Ron De Bruin's "Function RangetoHTML" into a your VBA Module from here:
Mail Range/Selection in the body of the mail
3) then concatenate the string including table by following the instructions in this video.
What you need starts at around the 7:30 min mark.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,884
Messages
6,175,174
Members
452,615
Latest member
bogeys2birdies

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