I have 2 CFs in a sheet that I would like to keep upon copy/pastes you can see the range and formulas below.
CF1 Range : B3:H1001
CF1 Formula : =($A3<>"")*(B3="") //This one higlights the empty cells in a given range
CF2 Range : A3:R1001 // This one highlights the row if the cell in R column is No.
CF2 Formula : =$R:$R="No"
Is there a way to protect these CFs or apply them again after copy paste ? Thanks !
From above replying, I could understand that you want to keep the conditional formats, which are
=($A3<>"")*(B3="")
forB3:H1001
and=$R:$R="No"
forA3:R1001
, even when the range is copied and pasted toB3:H1001
andA3:R1001
.If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.
Issue and workaround:
In the current stage, unfortunately, there are no methods for directly protecting the conditional formats in Google Apps Script. So in this case, as a workaround, I would like to propose to overwrite the conditional formats when the change of conditional formats and cells using OnChange event trigger.
Flow:
Usage:
1. Copy and paste sample script
Please copy and paste the following sample script.
Sample script:Please set the sheet name.
2. Install OnChange event trigger
Please install the OnChange event trigger to the function of
onChange
.3. Test run
As a test run, please copy and paste the range in
sheetName
. By this, the script is run by the OnChange event trigger.Note:
References: