U
U
under322020-07-31 09:42:47
Google Apps Script
under32, 2020-07-31 09:42:47

How to get around the problem with activating cell grouping in Google spreadsheets, with a protected sheet?

Due to the fact that an option was found for Excel with macros to allow row grouping when the sheet is protected, this does not work with Google Spreadsheets. Tried to write code on google apps script but it doesn't work. Is it possible to do a similar thing in google sheets.
1) An example of a macro for Excel:

Private Sub Workbook_Open()
    Sheets("Нагрузка").EnableOutlining = True
 
Sheets("Нагрузка").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowInsertingColumns:=True, AllowInsertingRows:=True, AllowFiltering:=True, UserInterfaceOnly:=True, Password:="feralas123"
End Sub

2) An example of how I wrote this in google-apps-script
function myFuction ()
{var sheet = SpreadsheetApp . getActiveSheet (); 
var protection = sheet.protect ().setDescription ( "Лист1" ); 
var unprotected = sheet. getRange ( 'Лист1!F5: Лист1!J1000' ); 
var sheet.
 protection.setUnprotectedRanges([unprotected]);}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Stoyanov, 2020-07-31
@stomaks

You can set limits on a sheet or a range.
More details here
https://developers.google.com/apps-script/referenc...
---
Maxim Stoyanov (stomaks), Google Apps Script developer .
g-apps-script.com
stomaks.me

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question