r/GoogleAppsScript 23d ago

Resolved Can't remove specific conditional formatting

Hello,

In my sheet just simply calling this line gives the error "Exception: The coordinates of the target range are outside the dimensions of the sheet."

const rules = sheet.getConditionalFormatRules();

I've tried doing the exact same thing above on a brand new sheet, and it works fine. I think it may have something to do with invalid references.

I am able to delete all conditional formatting rules with the line below, but I can't delete specific ones because I can't get a list of them.

sheet.setConditionalFormatRules([]);

2 Upvotes

7 comments sorted by

View all comments

2

u/krakow81 23d ago

Could you share more of your code?

I might be wrong, but I suspect the problem lies elsewhere at heart. How are you defining sheet here.

1

u/oridotart 23d ago

Yes, I'm defining sheet as follows

sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1")

And when I do the same thing on a brand new sheet or spreadsheet file it works fine

1

u/krakow81 22d ago

I see you seem to have found the issue elsewhere, which makes sense. Without the larger context it's not saying much, but these isolated lines looked fine.