ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VB Code help (https://www.excelbanter.com/excel-discussion-misc-queries/2880-vbulletin-code-help.html)

Christopher Anderson

VB Code help
 
Here is a portion of one of my VB Macros in Excel:

If Selection.Count 0 Then
MsgBox ("Average = ") & (RunningTotal / Selection.Count), vbInformation,
"Average"
End If

My question: How do I format the number (RunningTotal/Selection.Count) to
look like 0.000, instead of 0.0000000000000000?? What should my code look
like with the new formatting.

Thanks

Chris



Earl Kiosterud

Chris,

Try this:
....Format((RunningTotal / Selection.Count), "0.000")...
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Christopher Anderson" wrote
in message ...
Here is a portion of one of my VB Macros in Excel:

If Selection.Count 0 Then
MsgBox ("Average = ") & (RunningTotal / Selection.Count),
vbInformation,
"Average"
End If

My question: How do I format the number (RunningTotal/Selection.Count) to
look like 0.000, instead of 0.0000000000000000?? What should my code look
like with the new formatting.

Thanks

Chris






All times are GMT +1. The time now is 09:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com