EXCEL 公式運算

2015-02-18 7:55 am
A1 to A30 儲存格的總和於A31儲存格答案是=sum(A1:A30)即是30000,於A31儲存格怎樣可以設定公式不能超過30000,如超過30000就不能入數。請教教。謝!

回答 (2)

2015-02-18 5:04 pm
✔ 最佳答案
在輸入A31:
=IF(SUM(A1:A30)>30000,"不能入數 - sum is greater than 30000",SUM(A1:A30))

2015-02-19 03:30:02 補充:
唔明你所謂的'剔除( )計算全部總和',如以下的例子,那一個是你要的結果?
i) 3+(2)+4=7....剔除(2),只考慮3+4=7
ii) 3+(2)+4=12....剔除(),把(2)當正數處理,3+2+7=12

2015-02-19 04:06:07 補充:
至於'不能入數字眼同時會變紅色',加入之前的formula後,你可利用'Conditional formatting',做法如下:
1. select A31
2. go to menu bar, click 'Home'->'Conditional Formatting'->'New Rule'

2015-02-19 04:06:44 補充:
3. In 'New Formatting Rule' window,
- Select 'Format only cells that contain'
- Edit the Rule Description:
...Format only cells with: 'Specific Text', 'containing' '不能入數',
...Click 'Format', select 'Font' tag, in 'Color' -> select red color
4. click 'ok' to close all windows.

2015-02-20 05:35:24 補充:
如你要的是例子(ii)
我已在你的另一個發問題(qid=7015021800038,發問時間:2015-02-18 14:20:52)作答。你可用abs() function 去剔除負值。
至於例(i),你可用"=if(C1<0,"",C1)"代替abs().
2015-02-18 7:29 pm
估計要求「如超過30000就不能入數」,是指限制A1 to A30 儲存格範圍不能入數。
You may “Limit the Total” to prevent the entry of a value that will cause a range to exceed a set total, e.g. $30000. Now, the limit amounts are in cells A1:A30, and the formula checks the total in those cells.
1. Select cells A1:A30
2. Choose Data | Data Validation
3. Choose Allow: Custom
For the formula, use SUM to total the values in the range $A$1:$A$30. The result must be less than or equal to $30000:
=SUM($A$1:$A$30) <= 30000
4. Click OK
You may add the “Error Alert” message under Data Validation when necessary.


收錄日期: 2021-04-11 20:59:47
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20150217000051KK00103

檢視 Wayback Machine 備份