ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format to percent in msg box (https://www.excelbanter.com/excel-programming/322245-format-percent-msg-box.html)

Paul

Format to percent in msg box
 
Hi-

I have a variable defined as a single. I am displaying in a msgbox

dim totals as single
totals = 0.08
msgbox "Your totals equal to " & totals & ". Please make sure this equals
100%", vbinformation, "Totals"

How can I format variable totals so that it displays as a percentage in the
msgbox?
--
Thanks,
Paul

Ben

Format to percent in msg box
 
try

Sub iss()

Dim totals As Single
totals = 0.08
i = totals / 100 ' remove this line if it should display 8%
total1 = Format(i, "0.00%")
MsgBox "Your totals equal to " & total1 & ". Please make sure this equals
100%", vbInformation, "Totals"
End Sub


"Paul" wrote:

Hi-

I have a variable defined as a single. I am displaying in a msgbox

dim totals as single
totals = 0.08
msgbox "Your totals equal to " & totals & ". Please make sure this equals
100%", vbinformation, "Totals"

How can I format variable totals so that it displays as a percentage in the
msgbox?
--
Thanks,
Paul



All times are GMT +1. The time now is 07:18 AM.

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