I have multiple spreadsheets titled: Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. Each spreadsheet has 3 sheets titled: Plan, Class, and Coach. Each spreadsheet has near-identical formatting, the only difference being the height of merged cells in the first and last 8 columns of "Plan!".
I am constantly changing values in my spreadsheets, so while each spreadsheet has the same format, the values are very different. I also don't want to combine all of the sheets into one spreadsheet because I would have nearly 20 tabs to navigate through, making it very confusing and time consuming.
The problem I have is when I need to change something on every sheet. My sheet needs to be something I can update and change throughout the year depending on my needs, and as you would expect, it can be very annoying to have to open each individual sheet and change the same thing in every one. I have found the IMPORTRANGE function to be very useful in keeping my header rows and other constants updated between sheets, but I have not found a way to do so with conditional formatting, which is the most annoying thing to have to change.
I have multiple conditional format rules on each sheet, and I really need a way to have each sheet update automatically whenever I change or add a rule to say, "Monday".
- I only want to copy conditional format rules.
- I need each sheet to update whenever I update conditional format rules for "Monday"
This is what I wrote:
function copyConditional(){
var target = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Plan");
var source = SpreadsheetApp.openById("1RJVmCimFh24NbAlENJvH5pT3zRq_KLJmFdEWqUN_Fo8").getSheetByName("Plan");
var targetR = target.getRange('I3:AN59');
var sourceR = source.getRange('I3:AN59');
sourceR.copyTo(targetR,SpreadsheetApp.CopyPasteType.PASTE_CONDITIONAL_FORMATTING)
}
When I run my code, I get an error message stating, "Exception: Target range and source range must be on the same spreadsheet. (line 14, file 'Code')"
Now, I don't know if what I am looking to do is actually possible, but I am hoping there is some workaround to what I am trying to do. My experience with code is small, but I am starting to understand a lot more of it (all thanks to this great community at Stack Overflow!). I would appreciate any help you can give me.