简体   繁体   中英

VBA Formatting Not Putting 0 Into Excel Table

I have a VBA UserForm to input orders into an Excel table.

When the number is 0 instead of putting 0 into the excel table the cell is left blank.

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.

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.

Any help would be appreciated.

Thank You

Change #,### to #,##0

A 0 in that place instead means that it will put a number there, whereas a # is just a placeholder for a number.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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