2016-06-21 33 views
0

當我使用PercentRank函數時,消息框以「0.00」數字格式輸出數字。有什麼方法可以改變它嗎?最好是它出來作爲「00%」更改PercentRank函數輸出的數字格式

x = WorksheetFunction.PercentRank(relevant_Array, answer, 2) 
      If x > 0.7 Then MsgBox "WARNING: Price is more than 20% above the average price: " & x 
      If x < 0.3 Then MsgBox "WARNING: Price is more than 20% below the average price: " & x 
      If x > 0.3 And x < 0.7 Then MsgBox "Carry on: your price seems to be accurate: " & x 

回答

1

您是否嘗試過VBA的Format function

If x > 0.7 Then MsgBox "WARNING: Price is more than 20% above the average price: " & Format(x, "00%") 
0

你也可以試試這個...

If x > 0.7 Then MsgBox "WARNING: Price is more than 20% above the average price: " & Round(x*100,0) & ''%''