Convert Simple Excel Macro to Google Sheet Script [closed]

Try

function onChange(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
  if (sheet.getName() == 'Sheet1') {
    var range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn())
    range.sort({ column: 1, ascending: true })
  }
}

you will have to define a trigger on onChange function

onChange()

trigger