Add or subtract from column. Function?

Wondering if anyone has a code that would allow a component in the app to add or subtract from a column in the spreadsheet?

I can figure out the rest, just need some code help!

By code do you mean a google script that adds or subtracts from the entire column? If that is what you mean what would be the trigger that would cause this function to run?

1 Like

Yes. I think the solution to a currency (for me) would be to have items set at certain costs, and when a student clicks the button it subtracts from that column (and hopefully I figure out a way that it would also add that item to their profile)

I tried your set up but couldn’t get it to where the gold amount would be affected. :thinking:

I just want pretty simple. Item. Click. Gold is subtracted from the user tab, and item could be added to their profile or inline list.

I think that would mean I’d have a column for each item in the users tab and something would trigger true/false to determine if it shows in their row.

1 Like

@George_B I just reread what you said. Not from the entire column.

It would be a choice component to choose which user, and submitting would subtract a certain amount from the total in their cell of the currency column. Do you know how this could be achieved?

Without seeing the structure of the sheets I can’t give you details but I believe it could be done with a small script. The way I see it is the script would scan the sheet the form was saving the entry. It would see a new row, one that hasn’t been “processed”. It would then either add the purchased item to the inline list that would have a column that has the student name to link it to the student. And at the same time subtract whatever the amount of gold that that item costs from the students bank column. Then it would mark the item as paid for so on the next scan of the sheet, it would bypass that row of information.

Wouldn’t the currency example in work for you? Just modify it to have a column in the users tabel for each inventory items, then set up a formula in each of this columns using SUMIFS to use multiple criteria (user, item) to total up the number of items for each item column? @Christopher_Breen I feel like this would work for you too with your CYOA.

Let me just rephrase my answer honestly: I know WHAT you’re talking about, but have no clue how to do it. Lol.

Are you available to sheet-chat like we did for the avatar choice issue?

Hehe, I’m busy this weekend, so it would be sometime next week as the earliest. When I get a chance I’ll make a copy of your sheet and see what I can figure out. I don’t think it would be too complicated.

Similiar Solution.
This sounds similiar to a time slot issue where someone needed to subtract available time slots from a bank, and assign it to a user and show that the time slot is not longer available.
In your case the time slot would be the “Currency” items.

Hope you the solution here would bring you closer to a concept.

I made a copy of your sheet and and made some modifications. I deleted some tabs that seemed like testing or were redundent, so don’t be to concerned if my copy appears to be missing some things. I just did it to make it easier for me to visualize. I created 3 sheets. ItemUsersInventory (which I assume would go into your Players sheet), ItemChoiceResponses (which list an inventory and total cost of items purchased), and ItemChoices (which is a list of possible items for purchase). What I imagine is either an item displaying somewhere in your app, or a type of store where you select an item from a choice component. Then you would create a form button to purchase the item, with will submit the User and the Item into the ItemChoiceResponses sheet. The cost and image are determined automatically from the item purchases. The ItemUsersInventory sheet performs a series of COUNTIFS and a SUMIF to determine the quantity and the total cost for all items in that users inventory. The total Spent can be used to subtract from the users total gold. I’m not sure if this is exactly what you were looking for, but I think it should get you a lot closer. If an item is no longer available once it purchased, we can make a couple modifications. Right now, there is no limit to how many times an item can be purchased. See what you think of this first.

1 Like

WOW Thank you! This is looking good Jeff! I think I have it all set up. I definitely need to study up on array formulas because that seems to be the solution to a lot of things!

I just need to reset the purchases now, but I don’t want to delete something important ( I played around with it and seems I keep doing just that )

Got it! Thank you sir!

Good deal. Glad it worked for you.