Excel 2007 - 条件货币格式

时间:2010-06-06 16:36:05

标签: excel excel-2007

是否可以根据单元格的值设置列的货币(£/€/ $)?

例如,如果我确定在工作簿中使用的地址是美国,则工作簿货币将设置为美元。

这样可以节省为不同货币设置多个电子表格的时间。

提前感谢任何可以提供帮助的人。

诺尔

1 个答案:

答案 0 :(得分:1)

任何可能感兴趣的人我想出了以下内容,如果有更好的解决方法请告诉

'
'   Set the Currency of the worksheet
'
Public Sub setCurrency()

Dim eurFormat As String
Dim strFormat As String
' Euro currency format
eurFormat = "[$€-1809]#,##0.00"
' Sterling currency format
strFormat = "[$£-809]#,##0.00"


If Worksheets("ws-with-cell-value").Cells(1, 2).Value = "GBP £" Then
    Worksheets("ws1").Columns("C:C").NumberFormat = strFormat
    Worksheets("ws2").Columns("I:J").NumberFormat = strFormat
End If

If Worksheets("ws-with-cell-value").Cells(1, 2).Value = "EUR €" Then
    Worksheets("w1").Columns("C:C").NumberFormat = eurFormat
    Worksheets("ws2").Columns("I:J").NumberFormat = eurFormat
End If

End Sub

然后在workbook_activate()和Sub Worksheet_Change上调用此子例程以获取“ws-with-cell-value”

希望这可以帮助那些人

相关问题