我正试图格式化数字单元格,这是为印度客户在这种方式-24,33,000和外国客户喜欢2,433,000。
我尝试了这些数字格式,但我的输出格式随机变化。有时它是所需的格式,有时不是。你能帮帮我吗。真的很感激。谢谢
If InvoiceCurr <> "INR" Then
For Each c In ThisWorkbook.Worksheets("Invoice").Range("E15:F29").Cells
If Not (c.Value = "" Or c.Value = 0) Then
c.Value = Val(c.Value)
c.NumberFormat = "#,##0;-#,##0"
End If
Next c
ThisWorkbook.Worksheets("Invoice").Range("F30").NumberFormat = Val(ThisWorkbook.Worksheets("Invoice").Range("F30").Value)
ThisWorkbook.Worksheets("Invoice").Range("F34").NumberFormat = Val(ThisWorkbook.Worksheets("Invoice").Range("F34").Value)
ThisWorkbook.Worksheets("Invoice").Range("F30").NumberFormat = "#,##0;-#,##0"
ThisWorkbook.Worksheets("Invoice").Range("F34").NumberFormat = "#,##0;-#,##0"
Else
For Each c In ThisWorkbook.Worksheets("Invoice").Range("E15:F29").Cells
If Not (c.Value = "" Or c.Value = 0) Then
c.Value = Val(c.Value)
c.NumberFormat = "#,##,##0"
End If
Next c
ThisWorkbook.Worksheets("Invoice").Range("F30").NumberFormat = Val(ThisWorkbook.Worksheets("Invoice").Range("F30").Value)
ThisWorkbook.Worksheets("Invoice").Range("F34").NumberFormat = Val(ThisWorkbook.Worksheets("Invoice").Range("F34").Value)
'ThisWorkbook.Worksheets("Invoice").Range("F30") = Format(ThisWorkbook.Worksheets("Invoice").Range("F30"), "##\,##\,##\,##\,##\,##\,##\,##\,###.##")
ThisWorkbook.Worksheets("Invoice").Range("F30").NumberFormat = "#,##,##0"
ThisWorkbook.Worksheets("Invoice").Range("F34").NumberFormat = "#,##,##0"
End If
2条答案
按热度按时间vwhgwdsa1#
替换为以下格式定义:
和/或
根据所需格式
jdg4fx2g2#
要在VBA中使用动态格式的完整实现,请研究我的文章:
Indian number formatting of Currency in Microsoft Access and Excel
代码: