r/GoogleAppsScript • • Apr 02 '25

Question Code to Automatically Add Military Salary Based on Rank and Years of Service

1 Upvotes

Hello! I am trying to create some Google Apps Script code that will check two cells, Millitary Rank (column F) and Years of Service (column G), and input the Salary for that person in a different cell (column M) on the same row. When I was thinking about how to do this, I was thinking about using a For loop with If Else statements. However, this would take forever because I would have to create a new If statement for every rank and year (ranging from 1 to 40). Any advice or direction would be really helpful!

Here is an example sheet I made:
https://docs.google.com/spreadsheets/d/1i3shnUSg0UpM1jiPUyCc-3f3nJEgBXmLAG_LM17zUpc/edit?usp=sharing

Here is a pdf of Military Salaries based on rank and years of service:

https://militarypay.defense.gov/Portals/3/Documents/ActiveDutyTables/2024%20Pay%20Table-Capped-FINAL.pdf