I am new to the google sheets environment and my limited knowledge of VBA does not help. I would like to be able to delete range names from a cell or multiple cells selected by the "curser" on google sheets.
I did manage code deleting all named ranges from a sheet but that is not what I want. Your assistance will be appreciated.
Illustrate Active Cell and Named range circled in red
I would like the script to delete the named range map_4bf9.... in live cell C17. Preferably I would like to be able to select say range C17:H18 and let the script delete the named ranges from all those cells which are next to each other.
To do it manually in google sheets you will go to Data/Named Ranges and then search for the range name from the listing to the right and then manually delete it.
Google sheets select named ranges
The script removing all named ranges on a sheet was as follows:
function delRange(){ var namedRanges = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getNamedRanges(); for(i=0;i<namedRanges.length;i++){ namedRanges[i].remove(); } }
This is not quite what you were asking for, but it comes close I believe.
Image of Original Data:
Image of Active Ranges
Image of range After Running Code:
I think this version is closer to what you might be looking for because it just changes the values of the active cells in the array without actually changing the values in the range.
And it requires this helper function which breaks rangeLists into separate single cell rangelists
Using the same named range as before here is an image of the active range:
And here is the execution logs for this version:
Notice that no data in the original range or array has been changed
I got to thinking that this might be what you want. It's a rangeList of the named range missing the active cells