简体   繁体   English

VBA 格式化未将 0 放入 Excel 表中

[英]VBA Formatting Not Putting 0 Into Excel Table

I have a VBA UserForm to input orders into an Excel table.我有一个 VBA 用户窗体可以将订单输入到 Excel 表中。

When the number is 0 instead of putting 0 into the excel table the cell is left blank.当数字为 0 而不是将 0 放入 excel 表时,单元格将留空。

OrdersTable.ListColumns("Introducer Tier 2 Cash Fee Percentage").Range(NewRow + 1) = Val(tbSecondaryIntroducerCashFeePercent)
OrdersTable.ListColumns("Introducer Tier 2 Equity Fee Percentage").Range(NewRow + 1) = Val(tbSecondaryIntroducerEquityFeePercent)
OrdersTable.ListColumns("Introducer Tier 2 Cash Fee").Range(NewRow + 1) = Format(CLng(tbSecondaryIntroducerCashFeeNumber), "#,###")
OrdersTable.ListColumns("Introducer Tier 2 Equity Fee").Range(NewRow + 1) = Format(CLng(tbSecondaryIntroducerEquityFeeNumber), "#,###")

This is happening to the Introducer Tier 2 Cash Fee & Introducer Tier 2 Equity Fee sections.这发生在介绍人第 2 级现金费用和介绍人第 2 级股权费用部分。

Right now I am solving the problem with IF statements but I know in my bones that there is a simple fix I'm just not realizing what it is.现在我正在用 IF 语句解决问题,但我骨子里知道有一个简单的解决方法,我只是没有意识到它是什么。

Any help would be appreciated.任何帮助,将不胜感激。

Thank You谢谢你

Change #,### to #,##0#,###更改为#,##0

A 0 in that place instead means that it will put a number there, whereas a # is just a placeholder for a number.相反,该位置的0表示它将在那里放置一个数字,而#只是一个数字的占位符。

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

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