Created
September 14, 2022 02:30
-
-
Save palumbo/f80b8d98e5a3595f5b40efd3662ae9f3 to your computer and use it in GitHub Desktop.
Sorts payroll election order based on amount and percentage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction() { | |
let sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
let lastRow = sheet.getLastRow(); | |
for (var i = 1; i < lastRow; i++) { | |
let check1 = sheet.getRange(i+7,2).getValue(); // GETS FIRST VALUE IN COLUMN B | |
let check2 = sheet.getRange(i+6,2).getValue(); // GETS SECOND VALUE | |
if (check1 == check2) { | |
let amount = sheet.getRange(i+7,33).getValue(); | |
let percent = sheet.getRange(i+7,34).getValue(); | |
if (amount != "" || percent != "") { | |
Logger.log(i+7 + " | " + amount); Logger.log(i+7 + " | " + percent); | |
let rowToMove = sheet.getRange(i+7,1,1,35); | |
rowToMove.setBackground('red'); | |
sheet.moveRows(rowToMove,i+6); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment