This is great but it is not possible to drag down the function to different cells as the cell address is in "" annotations.
function ifBold() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Bold');
var cells = sheet.getRange('A2:A');
for (var i=1; i <= cells.getNumRows(); i++) {
var isBold = false;
if(cells.getCell(i, 1).getFontWeight() == 'bold')
isBold = true;
sheet.getRange(i+1, 2).setValue(isBold);
}
}
to be able to drag the function from one cell to the next cells you need to use this:
if you want to use it for one cell:
=ifBold(CELL("address"; A1))
or
=ifBold(CELL("address", A1))
; or , can be different due to your language region
new google sheets:
=myFunction(CELL("address",A1)&":"&CELL("address",A2))
or
old google sheets:
=myFunction(ADDRESS(row(A1),COLUMN(A1),4)&":"&ADDRESS(row(A2),COLUMN(A2),4))
you may need to change , to ; again for this. like:
=myFunction(CELL("address";A1)&":"&CELL("address";A2))
reference:
https://webapps.stackexchange.com/questions/10629/how-to-pass-a-range-into-a-custom-function-in-google-spreadsheets