将标题和更改格式添加到msgbox输出的2位小数位

时间:2015-06-05 21:14:27

标签: excel vba excel-vba

需要添加标题并更改以下代码的输出小数位(2位小数),但我遇到了问题。你能帮我吗?非常感谢

Couldn't match expected type `[Char]' with actual type `Person -> String' 

1 个答案:

答案 0 :(得分:0)

要在消息框中添加标题,请按以下方式使用:

Msgbox "My message",,"My title"

要获得两位小数,请使用以下格式:

Format(dTotalArea,"0.00")

使用点(。)作为小数点分隔符,即使您的区域设置需要使用逗号(,)。

所以你的代码看起来像这样:

Sub msgAlert()

MsgBox "First Response Time (hours)= " & _ 
 Worksheets("Parsing").Range("H21").Value & _
 vbCrLf & "Investigation Time (hours)= " & _
 Worksheets("Parsing").Range("I21").Value & _
 Format(dTotalArea, "0.00"),,"This is the title"

End Sub

如果有效,请告诉我。 :)

相关问题