Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9624

script for a button to add value of cell to existing value of cell on another sheet, google sheets

$
0
0

I'm trying to make a button on a spreadsheet for an apparel manufacturing business, I have one sheet that we use for stock on hand that then feeds requirements into two other sheets for cutting and sewing based on minimum stock levels, I want to create buttons on the sewing and cutting sheets where I can enter the amount of the item we have cut or sewn click the button and it adds it to stock levels

example, item A is 5 in stock we need 8, so sewing sheet says to make 3 (witch the sheet already does) but when I make that 3 then I want to be able to add the new ones into the stock on hand and minus the ingredients used from that stock on hand from a cell on sewing sheet.

I'm a complete newbie to script I understand the basics of using but barely anything about writing it

any advice would be greatly appreciated

EDIT: sorry super new to this still learning how to ask questions and still only kinda understand what I'm actually asking for, I have scoured the internet for the answer but was only able to find it for excel not google sheets. up until about 3 weeks ago i had never even used a spreadsheet so im kinda learing on the fly.

I have attached some images of the sheets I'm working on witch hopefully provides the information your asking for.

sewing req sheet

so on sheet "sewing req" if I made 5 black on black left faceplates I would put 5 in C2 then hit the "add" button I have put in D2 to run the script witch would do the following,

stock on hand sheet 1

it would add 5 to the existing total in C110 on sheet "stock on hand" (this cell has no equations in it just a number we manually enter during stocktakes) then,

stock on hand 2

it would also minus 5 from cells C78 and cells C66 on sheet "stock on hand" as these ingredients have been used up,

then it would clear the number out of cell C2 on sheet "sewing Req" I already have the script for the clear part.

I understand I would have to create a heap of these macro scripts for each individual button with minor changes to begging and end cell sources as the information jumps around a bit between the pages

EDIT

I have figured out a solution by frankenstiening some script

/** @OnlyCurrentDoc */function adjust() {  var ss = SpreadsheetApp.getActiveSpreadsheet();  var sourceSheet = ss.getSheetByName("sewing req");  var targetSheet = ss.getSheetByName("Stock on hand");  var New = sourceSheet.getRange("C2").getValue();  var Old = targetSheet.getRange("C10").getValue();  var ing1old = targetSheet.getRange("C78").getValue();  var ing2old = targetSheet.getRange("C66").getValue();  targetSheet.getRange("C10").setValue(New+Old);  targetSheet.getRange("C78").setValue(ing1old-New);  targetSheet.getRange("C66").setValue(ing2old-New);    sourceSheet.getRange('C2').clearContent();}

Viewing all articles
Browse latest Browse all 9624

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>