Google Apps Script: Compare One Cell to Another, then Increment Cell Value - excel

I'm not very experienced in programming, but I'm looking to do something specific with my Google Sheets document. As an example:
I buy fruit buy the box. Each type of box has a
certain amount of each fruit.
My customers have standing orders for
differing numbers of certain fruit platters I sell.
I need to figure
how many of each fruit box I need to buy to fulfil each customer's
order, with a minimum of wastage.
I keep running into circular dependancy errors when I try to work things out with my limited spreadsheet knowledge. Ideally what I'd like to do is have a script that:
Increments the "Amount to Buy" of Fruit Box #1 by 100 (they come in pallets of 100, I can't buy less)
If the amount of fruit with the best yield for that box (highlighted in green on the "Fruit Boxes" sheet. Fruit Box #1 is Cherry) is met, then the sheet moves onto the next fruit box.
At the moment I am able to get the sheet to tell me how much of each fruit box I need to buy to have enough of the "best yield" fruit that box contains, but I need it to take into account that the other boxes I need to buy also may contain some of that fruit.
My example sheet is here >> https://docs.google.com/spreadsheets/d/1tbI89jfY2ddAlyTN5VGaQ3nSRsgJcuR6Ev3I-YIdUoA/edit?usp=sharing
Note: Bonus points for anyone who can suggest a better way of displaying how many of each platter each customer requires. At the moment I'm using a very long and clunky IF, THEN statement in the "Required" column for each fruit platter, but I'm sure there must be a better way.
Thanks in advance for any help you can provide.

I'm not sure this is a Google Apps script question - are you planning to code a solution in Javascript, or are you happy to just use normal spreadsheet functions? I suspect the later, in which case you may be better off asking in https://webapps.stackexchange.com/questions/tagged/google-spreadsheets
Some functions that may be relevant to explore include SUMIF, SUMPRODUCT, HLOOKUP and VLOOKUP. I'm not sure I fully understand your question so I can't help you more!

Related

How to count all cards owned for a specific element in a card game documentation on excel?

Sorry about the confusing title, but I don't know how better to state it. I have an excel sheet documenting these cards from a card game that works off elements. I have the excel sheet that records all the stats for all the cards I know about, with the card names in column A, how many I own of that card in column B, and what colour that card is in column C. And I have some totals down the bottom as total cards owned. Anyway, I want to make a total owned for each element, like fire cards owned 7. But there are lots of cards, and I'm regularly editing it, so I want to make it automatically tally all the blue cards I own, including duplicates. If it is impossible, I might have to go through the tally weekly, but I figured I'd at least post this question.
Try something like this:
=SUMPRODUCT(--(Table of cards[column with card type]="Blue"),Table of cards[column with number of cards owned])
Edit: Maybe I should phrase it like this:
=SUMPRODUCT(--(Tbl[C]="Blue"),Tbl[B])
This article explains it well

Use Excel to optimise KFC order

Don't laugh, but, from time to time, my friends and I host a multiple-course KFC dinner, and I have a spreadsheet to optimise the order. This is to make sure we order the right combination of 'bucket'-type items (i.e. SKUs that contain multiple pieces, often of different types):
to minimise leftover items
to reduce the total cost
Here is the spreadsheet I currently use, and here's a screenshot:
To use it, you first specify the number of participants in A2, and what you want each person to have in E2:E6 (we're really only interested in the chicken, so 'sides' are treated as generic to simplify).
Here's the manual part, that I'd like to improve.
The next step is to look at the ideal totals for each item (F2:F6), and to try to set the right quantities (H12:H20) of the 'bucket'-type SKUs that I have recreated (A11:G20), so that the output totals (H21:M21) match the ideal totals (F2:F6).
The optimisation part is to get the deltas (H22:M22) as close to zero as possible, and to get the total cost (N21) as low as possible.
So, my question is: is there a way to do this better? I think Excel has some sort of Solver functionality, but I'm afraid I don't know how I'd go about even starting to use that, as my Excel skills are pretty rudimentary. Oh, and in case it makes a difference regarding functionality, I'm using Excel for Mac v16.37.
Any thoughts gratefully appreciated! :)
I can't take any credit for this, but am happy to say that GSerg left me a couple of comments that pointed me in the right direction, and I now have Solver set up to organise my chicken parties!
Here are the parameters for anyone who is curious:

Dividing people in to groups based on strength and rank

Edited:
after using Solver which Saulo Suggested I have managed to get excel sorting them in to groups up to 8 groups of 3. though am approaching troubles when going further ideally at this time I need to be able to do 18 groups of 3. but even with the same settings obviously adjusting for the increase in groups excel seems to belly up on the process and fails, any suggestions to adapt to this?
I am trying to figure out an easy and as accurate as possible without going too crazy with the math and formulas as I am basic with my excel coding (coding in general) to calculate the ideal groups of 3 based on rank and strength for a video game.
I want to pair the strongest with the weakest and then fill the gaps evenly for the 3rd person. so, that each team’s overall strength is the same roughly.
factors I have is a designated leader(rank) and an overall power level(strength).
doing this manually isn't too hard but trying to automate it is. any thoughts or suggestions would be amazing!?
something like this but automated which is where I am getting stuck, as I want to be able to add more players and adjust strengths as they come along.
Hope this makes sense.
Jordan, you have a classic situation to use "Solver". First of all, you have to make "Solver available in your Excel. Select Home -> Option -> Supplements -> Solver. Then, the solver button´s will be at the "Data" menu.
Solver is about solving a problem with especific conditions, changing specific cell, with specifc purpose. In your case, your purpose is creat teams with the minimal strength diference. A condition of your problem is that teams should have the same number of players. See how I organized the sheet.
Sheet
When do you open solver, the first field is "Seat Goal". Our goal (or purpose) is reduce the diference between teams as minimal as possible. So we selected the cell with the diference between teams. Then we have to tell to excel that our purpose is that cell have the minimal value (chossing "min").
Then we have to tell excel wich cells they can change values to achieve our goal. In this case, Excel can change the teams of player, so we select the cells with the teams.
Last we have to tell excel whats condition (or restrictions) of this problem. The first restction is that the total of player of team 1 is tree. The total of players of team 2 is, both, 3. Then we have to tell to excel what are the limits (superior and inferior) of values of variable cells. In this case, we chose superior or equal to 1, AND (other restrction) inferior or equal to 2.
Ok. Now we have a problem with specif goal, changing the value of specifc cells, with specif restriction. Now solver can work. Then choose the method of soluction "Evolutionary", Honestly, I do know the diference between the methods, but my experience is that evolutionary method works better than the others.
I recomend reading the excel tutorial on solver. At first, all of us think that is too dificult, but believe that is simpler than it seems.

Indexing and Calling Cell information in Excel

Alright so I use excel a lot because of its cross platform functionality and I'm fed up of some of the very long workflows I have to complete for a load of weekly reports I have to do.
I've been experimenting with this for about 2 weeks and I'm not happy with any of it.
I need to input several different reports into a spreadsheet. Except all of the reports the data is in a different order and there is no way to make them all the same format. So what I was hoping to do was to give each product line (theres 170-300 product lines on each report) a numerical value and then have the spreadsheet call the cells from the different pages using its numerical index. Similar to the most basic of tables in C/C++ (the only coding knowledge I have). I have experimented with Vlookup and Address but both cant be used together and address only returns the address of the cell (but there is no way to then get this to read the data out of the cell and then other pieces of information relating to that cell.
If anyone has any ways of helping me out with this then I would be massively appreciative. P.s. To keep this simple all the reports are manually inputted so they all have the same formatting just on different sheets.
You can use INDEX MATCH to match rows and columns,
First Sec Thi
A Apple Orange Banana
B Grape Peach Harambe
C Lime Steve Goat
=INDEX(A:D, MATCH("B",A:A, 0), MATCH("Thi",1:1, 0))
Will return 'Harambe'.

Marking an Excel Spreadsheet with a value range

I teach a budgeting course for my professional association. As part of that course, students are required to submit a draft budget as part of their marks. The budget template that I have to use is kindof set in stone. The association offers it's courses at various college locations and I can't just arbitrarily change it's contents.
That being said, marking this assignment is a pain in the neck! I'm looking for an easy way to be able to compare the values in a cell, and then mark it correct or incorrect, if it is within an expected range..
For example, students are required to estimate the expenses for the current year. If their estimate is within $200 +/- of what the answer key states, then I would mark their answer correct.
I am not a coder by trade, but rather an armchair coder who will search out and self teach what I need to solve my problem, so I'm not afraid of a bit of homework myself. I have not been able to find any solution so far. Right now, my students submit their assignment hardcopy, and I manually mark their spreadsheets. Tedious to say the least. Any searches I try to perform for academic marking of an Excel spreadsheet only return solutions to use Excel as a tracking tool for student marks, which is not what I'm looking for.
My college uses Desire2Learn as their online platform for content delivery, and students can submit their material electronically, I want an easy way to determine if they have completed the spreadsheet correctly.
Any help, or pointers in the right direction would be greatly appreciated!
There are probably several ways to tackle this problem but this might be something simple if the layout of the sheets doesn't change. You could create a worksheet with 3 sheets.
1. a sheet to copy their work into
2. "Master" sheet with the correct answers
3. "Grading" sheet that has formulas that calculate the difference (possibly within a range). For example IF(ABS(Sheet 1!B20 - Sheet 2!B20)>200,"Correct","Incorrect"). Calculates the absolute value of the difference between the same cell address on 2 different sheets then compares to the expected answer and returns Correct or Incorrect.
You would still have to copy their work into your master worksheet one at a time. Remember this only works if their worksheet layout doesn't change.
Post a rely along with a sample of the data if you need something more flexible.

Resources