format value in code

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,603
Office Version
  1. 2021
Platform
  1. Windows
I have the following code below which I need amended to format the value extracted from B1 for eg as $ 415,250.75 ("$#,##0.00")


the value is extracted using VBA but not formatted asrequired above

Code:
  strBody = strBody & "Those over 60 days amount to " & Sheets(4).Range("B1") & "  vbNewLine & vbNewLine



Your assistance is most appreciated
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hello,

You can use : Format(Range("B1"), "$#,##0.00")

or

Code:
[COLOR=#333333]strBody = strBody & "Those over 60 days amount to " & Format(Sheets(4).Range("B1"),[/COLOR]"$#,##0.00"[COLOR=#333333])[/COLOR]

Hope this will help
 
Upvote 0
Hi,
If the value in your cell is formatted as required then use Range.Text property to display in your code, what you see in the cell rather than it's underlying value

Rich (BB code):
strBody = strBody & "Those over 60 days amount to " & Sheets(4).Range("B1").Text & "  vbNewLine & vbNewLine"

Dave
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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