Help with formatting data in an email macro

Hootywho

Board Regular
Joined
Oct 11, 2010
Messages
90
Hello,

I am currently using an email macro that pulls information directly into the body of the email. I need help with formatting. The referenced cell is currently formatted to only show 2 decimals on the spreadsheet (19.11). The value that shows in the body is 19.1111111111111. I would like it to only show the 19.11. The following is a portion of my current code. What do I need to add to format that data in the email body?

Thanks in advance.

Code:
.body = Sheets("Homes Available").Range("f150").Value
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hello,

I am currently using an email macro that pulls information directly into the body of the email. I need help with formatting. The referenced cell is currently formatted to only show 2 decimals on the spreadsheet (19.11). The value that shows in the body is 19.1111111111111. I would like it to only show the 19.11. The following is a portion of my current code. What do I need to add to format that data in the email body?

Thanks in advance.

Code:
.body = Sheets("Homes Available").Range("f150").Value


Use "fixed" function in your formula
 
Upvote 0
Unfortunately that will not work. I have multiple entries of the below code and each are different. I cannot start with what you have recommended, .body = fixed, etc. I am looking to format each individual section as needed. Any other suggestions are greatly appreciated.
 
Upvote 0
I have included more of my current code to hopefully better relay my needs.

Code:
.Body = "Available" & Sheets("Homes Available").Range("f150").Value & vbNewLine & "Comments - " & Sheets("Custom").Range("f151").Value & vbNewLine & "Prospects - " & Sheets("Prospects").Range("f152").Value

My goel is to have only the "Comments", Custom "F151" value formatted as such, 20.01 in the email body and not 20.0111111111. Unless I missed something, the recommendation did not work. Thanks!
 
Upvote 0
Hi,

You could use

Code:
Sheets("Custom").Range("f151").[COLOR=red]Text[/COLOR]

Or if it's always going to be the same format in the cell you can extract the first 5 characters using Left from the Value?

Code:
& Left(Sheets("Custom").Range("f151").Value, 5)
 
Upvote 0

Forum statistics

Threads
1,224,557
Messages
6,179,510
Members
452,918
Latest member
Davion615

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