### 如果“0”，則保持單元格為空

#### [英]If “0” then leave the cell blank

I am trying to create a simple ledger and on the far right of the "Book" it totals any debit/credit that I input. But instead of leaving the unused rows blank, it keeps repeating the latest total to the bottom of the page.

How Can I make that cell blank if the equation equals 0?

``````=H15+G16-F16
``````

is the formula I am currently using.

## 5 个解决方案

### #1

19

You can change the number format of the column to this custom format:

``````0;-0;;@
``````

which will hide all 0 values.

To do this, select the column, right-click > Format Cells > Custom.

### #2

6

Use `=IF(H15+G16-F16=0,"",H15+G16-F16)`

### #3

1

An accrual ledger should note zeroes, even if that is the hyphen displayed with an Accounting style number format. However, if you want to leave the line blank when there are no values to calculate use a formula like the following,

`````` =IF(COUNT(F16:G16), SUM(G16, INDEX(H\$1:H15, MATCH(1e99, H\$1:H15)), -F16), "")
``````

That formula is a little tricky because you seem to have provided your sample formula from somewhere down into the entries of the ledger's item rows without showing any layout or sample data. The formula I provided should be able to be put into H16 and then copied or filled to other locations in column H but I offer no guarantees without seeing the layout.

If you post some sample data or a publicly available link to a screenshot showing your data layout more specific assistance could be offered. http://imgur.com/ is a good place to host a screenshot and it is likely that someone with more reputation will insert the image into your question for you.

### #4

1

Your question is missing most of the necessary information, so I'm going to make some assumptions:

1. Column H is your total summation
2. H列是總和
3. You're putting this formula into H16
4. 把這個公式代入H16
6. 列G是對求和的補充。
7. Column F is deductions from your summation
8. F列是求和的減法
9. You want to leave the summation cell blank if there isn't a debit or credit entered
10. 如果沒有一個借方或貸方進入，你想要離開求和單元。

``````=IF(COUNTBLANK(F16:G16)<>2,H15+G16-F16,"")
``````

`COUNTBLANK` tells you how many cells are unfilled or set to "".
`IF` lets you conditionally do one of two things based on whether the first statement is true or false. The second comma separated argument is what to do if it's true, the third comma separated argument is what to do if it's false.
`<>` means "not equal to".

The equation says that if the number of blank cells in the range `F16:G16` (your credit and debit cells) is not 2, which means both aren't blank, then calculate the equation you provided in your question. Otherwise set the cell to blank(`""`).
When you copy this equation to new cells in column H other than `H16`, it will update the row references so the proper rows for the credit and debit amounts are looked at.

CAVEAT: This equation is useful if you are just adding entries for credits and debits to the end of a list and want the running total to update automatically. You'd fill this equation down to some arbitrary long length well past the end of actual data. You wouldn't see the running total past the end of the credit/debit entries then, it would just be blank until you filled in a new credit/debit entry. If you left a blank row in your credit debit entries though, the reference to the previous total, `H15`, would report blank, which is treated like a 0 in this case.

COUNTBLANK告訴您有多少單元格未填充或設置為“”。如果讓你有條件地做兩件事中的一件，基於第一個命題是真還是假。第二個逗號分隔的參數是如果它是真的，第三個逗號分隔的參數是如果它是假的，該怎么做。<>表示“不等於”。公式中說，如果在F16:G16(你的信用卡和借記卡賬戶)范圍內的空白單元數不是2，也就是說兩者都不是空白的，那么計算出你在問題中提供的方程。否則將單元格設置為空(“”)。當您將這個等式復制到H16以外的H列中的新單元時，它將更新行引用，以便查看信用和借方數量的正確行。注意:如果您只是在列表的末尾添加積分和借位項，並希望運行的總數自動更新，那么這個等式是有用的。你可以把這個方程填到一個任意的長長度，直到實際數據結束。當你填寫新的信用/借貸分錄時，你不會看到超過貸方/借方分錄的運行總數。但是，如果您在您的信用卡借記條目中留了一個空行，則對之前的總數H15的引用將報告為空，在這種情況下，這將被視為0。

### #5

0

An example of an IF Statement that can be used to add a calculation into the cell you wish to hide if value = 0 but displayed upon another cell value reference.