简体   繁体   中英

Make one cell's value dependent on another's in Google Sheets

I am trying to setup a doc to keep track of my AWS instances. How would I go about setting up a script so that my "Cost" cell would be dependent on the Instance Type. For example, if I am adding a new instance, and I add "t2.micro" in the "Instance type" column the "Cost" cell would automatically populate with a set value. Any help or direction to relevant documentation would be greatly appreciated!

One path is to use the LOOKUP function.

With instance and cost being columns A and B, you'd make a list elsewhere of your options (t2.micro/$200). In the linked example I did it on the same page in columns G/H (but you could put it on another page or elsewhere).

I then set Data>Validation>List from a Range for Column A to be the values in column G. That give me a nice drop down of the instance types.

In Column B, I set the function =LOOKUP(A1,$G$1:$H$4) and drag it down. It references the value in cell A1 (instance) and then compares it to your list to pull the cost.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM