I have created a tab in the menu bar to hold my Schedule function. This is meant to highlight cells with italicized text to a bright yellow. When I run the script below, I get an error reading: Exception: The starting column of the range is too small.
function onOpen() {
var ui = SpreadsheetApp.getUi();
var menu = ui.createMenu("Scheduling");
menu.addItem("Schedule","schedule");
menu.addToUi();
}
function schedule() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("CANVAS");
var col = ss.getLastColumn();
var row = ss.getLastRow();
for (var i = 1; i <= col; i++) {
for (var j = 1; j <= row; i++) {
if (ss.getRange(i,j).getFontStyle() == "italic") {
ss.getRange(i,j).setBackground("#fff2cc");
j = j+1;
} else {
j = j+1;
}
i = i+1;
j = 0;
}
}
}
Try it this way: