VBA变体MsgBox格式百分比(%)

时间:2012-06-28 15:35:31

标签: vba formatting msgbox

Sub PctTest()
   Dim Third As Variant
   Third = 1 / 3    
   MsgBox (Third)
End Sub

如何让msgbox将变量“Third”显示为33.33%?我知道如何格式化单元格,但我已经环顾四周,不明白如何格式化这样的变量。提前谢谢 - 汤米

2 个答案:

答案 0 :(得分:0)

怎么样:

   Dim Third As Variant
   Third = Format(1 / 3, "##.00%")
   MsgBox (Third)

答案 1 :(得分:0)

您可以使用内置:FormatPercent(1 / 3, 2)