且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查单元格是否格式化为货币?

更新时间:2023-11-29 13:42:22

假设您使用$作为货币,则可以尝试以下操作:

Assuming you are using $ as your currency, you can try this:

Dim strFormat as String

strFormat = Range(StringColumn & StringRow).NumberFormat

If InStr(1,strFormat,"$") = 0 Then  'not a currency format

    MsgBox "Test Failed at " & StringColumn & StringRow  
    Exit Sub  

Else: MsgBox "Valid format for cell " & StringColumn & StringRow  

End If

如果您使用其他货币,请用您的货币符号替换$.

If you have another currency, replace the $ with your currency symbol.