【问题标题】:VBA NumberFormat ImplementationVBA NumberFormat 实现
【发布时间】:2018-04-07 19:18:16
【问题描述】:

NumberFormat 似乎是一个简单的函数,但我无法让它工作是一个相当简单的案例。在下面的代码中,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 

如果我用“会计”替换特定格式,它就不起作用。请帮忙!

【问题讨论】:

标签: vba excel number-formatting


【解决方案1】:

您要求 VBA 减去 2 个字符串 "...($*" - "??_.." 所以这是类型不匹配。

【讨论】:

  • 描述问题的有趣方式。
  • 谢谢你成功了,我的其他问题消失了,因为代码的另一部分覆盖了你好的格式化方法!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多