Home > other >  Using Google Script to extract conditional formatting from a google sheet so I can reuse it
Using Google Script to extract conditional formatting from a google sheet so I can reuse it

Time:07-13

I am familiar with writing conditional formatting rules in Google script.

I have a Google sheet that I have inherited that has been developed over a long period and conditional formatting rules have been manually inserted.

I am looking to copy all of the conditional formatting out of that google sheet using google apps script. The sheet has around 50 columns with many drop downs, and each dropdown, or combination of dropdowns, applies formatting. I think there are over 100 rules.

It would be VERY useful if I could get the conditional formatting out in a format that I could modify as needed and apply other (similar) sheets.

Any suggestions?

Mark

CodePudding user response:

SUGGESTION

Note: We normally do not code for you, but in this case I have a sample script that I can share with you that was derived from the samples of these Spreadsheet App classes listed below:

You can try using these Spreadsheet App classes in Apps Script:

  • enter image description here

    • Save the script as a enter image description here

      • You can highlight any range that contains the Conditional Formatting that you'd like to copy to another sheet tab, then press the custom menu. It will show you the criteria type used and its value, as seen here (this sample was done on the CURRENT sheet) :

      enter image description here

      • If you press the Yes button, you will be prompted to change these details below:
      1. Update the Criteria Value Or you could use the default value by just pressing Ok to go to the next step:
      2. Type the Destination Sheet name
      3. Type the Range (in A1 Notation format) where you want to apply the copied Conditional Formatting

      enter image description here

      • After that, on the DESTINATION sample sheet, the Conditional Formatting has been applied to the range.

      enter image description here

  • Related