Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Double Sorting on Google Sheets

$
0
0

My sheet has a drop-down menu with options 1.-4. in column C.

I want it to then further sort each option segment using column A. So that option 1. is sorted A-Z separately from option 2. etc. How can I modify the script to do that ? I assume I need to define some sort of ever-changing range based on option is column C.

To sort it on edit I use this script:

function onEdit(event){  var sheet = event.source.getActiveSheet();  var editedCell = sheet.getActiveCell();  var columnToSortBy1 = 3;  var columnToSortBy2 = 1;  var tableRange = "A4:G34";  if(editedCell.getColumn() == columnToSortBy1){       var range = sheet.getRange(tableRange);    range.sort( { column : columnToSortBy1 } );  }} 

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>