1
votes

Hi I am looking for a script or a drag/click function to mass apply conditional formatting on multiple sheets.

All of my conditional formattings is in "Wish" sheet

I would like to apply the conditional formatting to other sheets (up to 20).

In the script, I could apply the conditional formatting one sheet at a time or mass apply since I know all of the sheet names.

1

1 Answers

4
votes

Conditional formatting also belongs to formatting so you can use copyFormatTo.

Since you didn't provide any more information ymmv.

function copyFormatting() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var wishRange = ss.getSheetByName("Wish").getDataRange();
  var targetSheetNames = ["Sheet1", "Sheet2"];

  targetSheetNames.forEach(function(sheetName) {
    wishRange.copyFormatToRange(
      ss.getSheetByName(sheetName), 
      wishRange.getColumn(), 
      wishRange.getLastColumn(), 
      wishRange.getRow(), 
      wishRange.getLastRow());
  });
};