I am trying to sort data descending based upon column B (2) which has different numbers in each cell. EG: B8 = 99, B14 = 70, etc. I'm intending for it to autosort and do it onEdit. I'm not good at coding, like at all. So I watched a YouTube vid and came up with this, but it still doesn't work.
function autoSort(e){
const row = e.range.getRow()
const column = e.range.getColumn()
const ss = e.source
const currentSheet = ss.getActiveSheet()
const currentSheetName = currentSheet.getSheetName()
if(!(currentSheetName === "Roster" && column === 9 && row >= 8)) return
const range = currentSheet.getRange(8,5,21,22)
range.sort({column: 2, ascending: false})
}
function onEdit(e){
autoSort (e)
currentSheet.getRange(8,5,21,22)
defines the range "E8:Z28" andrange.sort({column: 2, ascending: false})
will sort that range based on the second column (Column F). Column B (which is the column that you describe in your question) NEVER comes into it. You say but it still doesn't work. Would you please describe EXACTLY what you expect to happen, and EXACTLY what happens instead. If there was an error message (which I doubt), please show the full message.