简体   繁体   English

VBA NumberFormat实现

[英]VBA NumberFormat Implementation

NumberFormat seems to be a straightforward function but I can't get it to work is a rather simple case. NumberFormat似乎是一个简单的函数,但是我无法使其正常工作。 In the code below VBA tells me "Type Mismatch". 在下面的代码中,VBA告诉我“类型不匹配”。

For j = 1 To last_column + 1
    For f = 2 To total_tranches + 1
        If allocation(f - 1, j - 1) = Empty And j <> 1 Then
            Allo1.Cells(AlShares.Row - 1 + f, j + 1) = 0
        Else
            Allo1.Cells(AlShares.Row - 1 + f, j + 1) = allocation(f - 1, j - 1)
            If j = 1 Then Allo1.Cells(AlShares.Row - 1 + f, j + 1).IndentLevel = 1
            If j = 2 Then Allo1.Cells(AlShares.Row - 1 + f, j + 1).NumberFormat = "_($*#,##0_);_($*(#,##0);_($*" - "??_);_(@_)"
        End If
    Next f
Next j 

And if I replace specific formatting with "Accounting" it just does not work. 而且,如果我将特定格式替换为“会计”,则无法使用。 Please help! 请帮忙!

您要求VBA减去2个字符串“ ...($ *”-“ ?? _ ..”,因此类型不匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM