I have a roster that has (on sheet 1 ('Roster')): Name, 1st Week of Attendance, 2nd Week of Attendance, and then other non-relevant data.
On the second sheet ('Contact Info' it has Name, a cell that combines the text from 1st week and 2nd week, and then contact data columns (phone, email, address, etc.).
The important note here, for the second sheet, is that columns A and B are formulas that just get the value of 'Roster'!A and 'Roster'!B:C (through a formula that concates) respectively.
'Roster'
'Contact Info'
I would like to be able to sort all the columns on 'Roster' by Column B and have it also move the contact info correctly. Here is the first part of the code I tried:
function onEdit(e) {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const rosterSheet = ss.getSheetByName("Roster")
const rosterRangeOne = rosterSheet.getRange("A2:J24");
const rosterRangeTwo = rosterSheet.getRange("A27:J31")
const contactSheet = ss.getSheetByName("Contact Info")
const contactRangeOne = contactSheet.getRange("B2:L24");
rosterRangeOne.sort({column: 2, ascending: true});
rosterRangeTwo.sort({column: 2, ascending: true});
contactRangeOne.sort({column: 2, ascending: true});
ss.toast('Sort complete.');
}
I did give some other code a shot, but it was janky and didn't actually sort the contact info correctly since it would move around the formulas and then be out of order.
The gist is that I want to sort two sheets based on two ranges using only one column as the column to sort by (reference).
Update: Still have made no progress on this. Not sure if it is even possible at this point.