我在下面使用了Google脚本
function sumWhereIsFontWeight(rangeSpecification,) {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var range = sheet.getRange(rangeSpecification);
var x = 0;
for (var i = 1; i <= range.getNumRows(); i++) {
for (var j = 1; j <= range.getNumColumns(); j++) {
var cell = range.getCell(i, j);
if(cell.getFontWeight() == 'bold')
x += parseFloat(cell.getValue());
}
}
return x;
}
然后使用公式=SUMIF(A:A,"A"&sumWhereIsFontWeight(B1:B6),B1:B6)
但是不能获得标准值为“ A”的仅加粗数字之和的期望结果“ 10”。检查所附图片
答案 0 :(得分:0)
=ArrayFormula(SUM(IF(isbold("A1:B10"),A1:B10,0)))
function isBold(rangeSpecification) {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var range = sheet.getRange(rangeSpecification);
var result = [];
var numRows = range.getNumRows();
var numCols = range.getNumColumns();
var row = [];
for (var i = 1; i <= numRows; i++) {
row = [];
for (var j = 1; j <= numCols; j++) {
var bold = (range.getCell(i,j).getFontWeight() === 'bold');
row.push(bold);
}
result.push(row);
}
return result;
}
添加新的粗体单元格后,自定义功能不会自动更新。您需要重新输入公式。