2017-08-17 59 views

回答

2

而不是

ws1.Range("C2: C" & p).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* " - "??_);_(@_)" 

嘗試

ws1.Range("C2: C" & p).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* "" - ""??_);_(@_)" 

注意雙引號-""

+0

感謝@Mrig爲幫助這一招解決了我的問題.... –

1

看到你的輸入,我假設你已經做到了這一點:

A.選擇與所請求的數字格式的單元格。

B.運行下面的代碼:

Public Sub TestMe() 
    Debug.Print Selection.NumberFormat 
End Sub 

看到立即窗口中的結果,並從那裏使用它。

然而,代碼應該是這樣的:

Public Sub PrintMeUsefulFormat() 

    Dim strFormula As String 
    Dim strParenth As String 

    strParenth = """" 

    strFormula = Selection.NumberFormat 
    strFormula = Replace(strFormula, """", """""") 

    strFormula = strParenth & strFormula & strParenth 
    Debug.Print strFormula 

End Sub 
相關問題