Google Scripts – IF Statement and VLOOKUP Syntax Translation

google sheets

Not sure if this is the right place to ask (I've been trolling around the web looking for the right place and after a few months decided to just throw my question out there), but here goes:

I've been working with Nested IF Statements and Vlookup in Google Sheets, and I'm looking to do similar things using Google Scripts.

1) There are quite a few, but for the purpose of the question I'm just going to isolate it to one. I have a region of cells, Name (B2), Source (B3), Duration (C1:C2 (Merged Cell)). What I want is an IF statement in Google Scripts that follows the logic of "If C2:C3 = or < 0, clear B2:C3, if not reduce C2:C3 by 1." If there is syntax for the IF statement that allows me to add multiple actions if my conditions are not met, that would also be extremely helpful.

2) Additionally, how can I do a Vlookup in response to a positive or negative response to the above IF statement? As an example, let's say that if C2:C3 > 0, I want some other cell, Resource (E2), to be reduced or increased by an amount— but to get that amount, it has to go to the cell called Source (B3) and Vlookup the Name (B2) on another sheet.

I've attached a link to a simplified and editable version sheet just in case a visual representation would help, but by no means feel obligated to modify it if you don't want to. I just want to know the syntax.

https://docs.google.com/spreadsheets/d/1TaMobaK3jHFNIiyYHi-wRRUzH0vSrdb2X04784gmbow/edit?usp=sharing

Best Answer

feel free to edit green cells as you fit - everything should get re-calculated (for convenience calculation area is in one sheet ...of course it can be distributed in separate sheets)

demo spreadsheet: https://docs.google.com/spreadsheets/d/