I'm trying to use a macro to check the top row of my sheet and automatically center align all cells that have only a dash. Right now, it looks like my code is running, but it's not doing anything:
function CenterAlignAllDashes() {
var spreadsheet = SpreadsheetApp.getActive();
var topRow = spreadsheet.getRange('A1:1');
var topRowValues = topRow.getValues();
for (let i=0; i < topRowValues.length; i++) {
if (topRowValues[i] == '-') {
topRow[i].setHorizontalAlignment('center');
}
}
};