I am a 10 years old boy. I created an app / game with google sheets that I shared with my friends: it is a kind of "virtual city", with shops (with related product catalogs and prices, to be purchased with your own virtual budget) ... but I'm going crazy trying to find the solution to this problem.
I did such a thing:
This example refers to Macdonald's. I put in the first column (players) the name of the players, in the second column (products) a validation of the data in which I insert all the macdonald's products, in the third (price) you can find the unit price of the product, in the fourth (quantity) one cell without formulas where to enter the quantity, and in the fifth (total) I put the formula: quantity x price. My problem is the BUTTON. To the "complete order" button I have assigned a macro that COPY and PASTE under all the informations of the order (for example Riccardo, salad, 5.00 € ...) and once copied it cancels them to consent to order other products.
So:
the macro I created (which script is:
function macro_vera(){
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('E12').activate();
spreadsheet.getRange('E5:I5').copyTo(spreadsheet.getActiveRange(),
SpreadsheetApp.CopyPasteType.PASTE_VALUES,false);
spreadsheet.getRange('G12').activate();
spreadsheet.getActiveRangeList().setNumberFormat('[$€-2]\\#,##0.00');
spreadsheet.getRange('I12').activate();
spreadsheet.getActiveRangeList().setNumberFormat('[$€-2]\\#,##0.00');
spreadsheet.getRange('F5').activate();
spreadsheet.getActiveRangeList().clear({contentsOnly:
true,skipFilteredRows:
true});
spreadsheet.getRange('H5').activate();
spreadsheet.getActiveRangeList().clear
({contentsOnly:true,skipFilteredRows:
true});
};
) HAS COPIED the order informations (salad ...) and PASTE it below.
But if we intend to buy, for example, three big macs that cost 10.00 each, then the total is 30.00 €, the previous informations (salad ...), when the button is pressed, will be replaced (overwritten without leaving a trace) and will be exchanged with the new ones we just added (big mac ...). I understood that the only solution is to edit the button macro script.
Can anyone tell me the commands and syntax I have to use to solve the problem?
How can I do?
thanks
Related
I am using Google Sheets to evaluate data from a Zoho Form. I would like to sort the raw data from spreadsheet 1 ('Raw Data') into 3 new spreadsheets depending on 2 specific keywords found in 2 different columns in 'Raw Data'.
For context - the keywords for the first column (column 'G') are:
Ordered
Stock
Preordered
the keywords for the second column (column 'F') are:
B2B
B2C
There are a total of 6 possibilites that need to be accounted for: ordered & B2B, ordered & B2C, stock & B2B, stock & B2C, preordered & B2B, preordered & B2C.
If for instance a form is submitted for 'Ordered' and 'B2B', then a specific succession of rows must be transferred to the corresponding 'Ordered' spreadsheet because of Zoho Forms' nature of staggering the submitted information horizontally in the 'Raw Data' sheet. These rows will change depending on which one of the 6 combinations is chosen in the Form.
The 3 new spreadsheets will be named according to the keywords found in column 'G'.
So far I have been working with a Query in the new sheets to pull the needed information from the 'Raw Data' spreadsheet, however this hasn't proven to work as intended as Zoho Forms creates a new row rather than filling an existing one, causing the query to skip the newly created row and therefore not pulling any data.
Here is the Query, maybe it'll help identify what I am looking for:
=IF('Raw Data'!G6="Ordered", IF('Raw Data'!F6="B2B",QUERY('Raw Data'!A6:DN6,"SELECT A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T ORDER BY C desc LIMIT 1"), QUERY('Raw Data'!A6:DN6,"SELECT A,B,C,D,E,F,G,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR,AS,AT,AU ORDER BY C desc LIMIT 1")))
I have found someone who posted a Script similar to what I am looking for, however it is missing that conditional aspect to it. Here is the script, maybe it can serve as a good starting point. (all credit for this code goes to Mike Steelson):
function moveData() {
var ss = SpreadsheetApp.getActiveSpreadsheet()
var rng = ss.getSheetByName('Sheet1').getRange('A2:C2')
ss.getSheetByName('Sheet2').getRange(ss.getSheetByName('Sheet2').getLastRow()+1,1,1,3).setValues(rng.getValues())
rng.clearContent()
}
I am quite new to building these sort of things so please forgive me if the Query and my overall explanation isn't the best, if you have any questions I'll try my best to elaborate!
Cheers,
Rupert.
I am currently attempting to find the ideology score for New York State Senate Members using this methodology (U.S. Senators). To do so I am attempting to pull the name of Senators who are sponsors and their co-sponsors from this NYS bill search website. I am doing this through a Google Sheet. This is working but is taking an extraordinarily long time. Is there any way that I could speed up this process in Google Sheets?
An additional question. Say I compile a sheet that contains the sponsors and their co-sponsors, for a certain number of bills. It would look like the image below. How would I then go about converting this into a sheet, wherein each cell of the table, I put the number of times the senator for the row cosponsored a bill introduced by the senator for the column?
You are loading too many times each Bill n° (63 * 2 = 126). Load one time each Bill n° in a specific tab, then apply the search in the relative tab with indirect function. I have prepared 2 Bill n° in this spreadsheet.
https://docs.google.com/spreadsheets/d/1Ojs3wOrbw5ww8VTrBOWSLXp7cs53hWPF4AWadayQbow/edit?usp=sharing
delete all formulae in your sheet
use this in C5:
=INDEX(IF($B6:$B="",,IFNA(VLOOKUP(REGEXEXTRACT($B6:$B, " (.*)$"),
TRIM(SPLIT(FLATTEN(SPLIT(QUERY(IMPORTHTML(
"https://nyassembly.gov/leg/?term="&$A$2&"&bn="&C$2, "table", 1),
"select Col2 where Col1 matches 'SPONSOR|COSPNSR'"), ","&CHAR(10), 1)&
{"×Y (Sponsor)"; "×Y"}), "×")), 2, 0), "N")))
and drag to the right for about 50 columns. then select those 50 columns (C6:AZ) and press CTRL+C then CTRL+SHIFT+V this step is necessary because you got over 500 columns with bills and google sheets has a limit on how many import functions are allowed per spreadsheet (from a test run I made, its 190 imports for me)
for the count use this in A6:
=INDEX(IF(B6:B="",,MMULT(IFERROR(REGEXMATCH(C6:100&"", "Y"), 0)*1,
SEQUENCE(COLUMNS(C6:100))^0)))
demo sheet
final sheet
fun fact lol:
total bills: 471
total sponsorships: 1670 out of 29673
total no-sponsorships: 28033 out of 29673
I have a google sheet where it will record payment done in paypal. So basically the users will enter address in all way, so to reduce the errors I have all the possible address the user might enter (This is because this is a payment system for residents in my residential area so I have all the user's address in database). So can anyone help me to find a formula it will find the actual address in "USERNAMES" worksheet and only take the house number and street from the actual data. I have attached some images to explain myself better. I want the formula to be in worksheet "Paypal 2". Please guys I need this help.
https://docs.google.com/spreadsheets/d/1bM8l6JefFsPrlJnTWf56wOhnuSjdIwg3hMbY1tN1Zp8/edit#gid=0 - Link to my google sheets
The address entered by users
The sheet to look up for the actual address
Sheet to split the house number and street
Try this:
Delete your formulas from 'Payment Configuration'!B3:C3. (This will temporarily remove all results from B3:C.
Place the following formula into cell B3:
=ARRAYFORMULA(IF(LEN(PaypalData1!C3:C),PROPER(REGEXEXTRACT(PaypalData1!L3:L, "(\d+)[,\s]+([^,]+\d+)")),))
REGEXEXTRACT allows for extracting more than one grouping, as I've done with this formula; so this should produce a uniform result for B3:C.
The RE2 expression reads "Find the first number(s) followed by any number of commas or spaces and extract the number portion as group one; then find any string after that which does not contain a comma and ends in any number of digits and extract that as group two."
Okay, I will try to explain in words what Im trying to accomplish, hoping that someone will be able push me in the right direction.
I have two different google spreadsheets:
One named ”Ads_sent_in” containing a couple of different columns that is automatically filled in by a PHP file on my website.. (its a list of file uploads that is being uploaded through a web-form). These are clients that uploads adverts (pdf’s) that are to be put in a magazine for print.
One of the columns in ”Ads_sent_in” is called ”Ordernumber” and contains a specific, unique number for the advert.
the other spreadsheet named ”Magazine_name_03-2019”. This is where all the adverts a placed on the different pages in the magazine, all in one spreadsheet. Each advert is represented by 1 row and 3 columns of info/data.
They are: Advertisers name/client name - advert size - ordernumber (Same number as in the other spreadsheet above in point 1.
Now,
I want do make a script that will be able to search the ”Ads_sent_in” spreadsheet for the ”ordernumber”, and find the same ”ordernumber” in the other spreadsheet ”Magazine_name_03-2019”.
If there is a match, the textcolor of ”ordernumber” (and also if possible, the cell which is always located one step/column to the left of where ”ordernumber” is) should be changed to green.
If no match, do nothing.
Is this possible?
=============================
EDIT
I pick up the ordernumber from the Ads_sent_in sheet using this bit of code:
var ordernumber = sheet_Ads.getRange(sheet_Ads.getLastRow(), 1).getValues();
After that I think all I need is a function that will search the Magazine_name_03-2019 sheet for the ordernumber I get from above..
The best scenario would be if that function could search a whole spreadsheet (both columns and rows) for the ordernumber and return the cell (for example 'D5'). I don't need any values returned, I just need to know where this ordernumber is located, in what cell in the Magazine_name_03-2019 sheet.
Then store the cell location (for example 'D5') in:
var ordernumber_loc = sheet_Magazine_name_0319.getActiveCell ?
I'd like to back off two columns to the left of the ordernumber_loc above if possible and store it in another variable
var client_cell_loc = ordernumber_loc - "2 columns"
From there on I want to change the color of client_cell_loc text to green and make it bold:
var style = SpreadsheetApp.newTextStyle()
.setForegroundColor("green")
.setBold(true)
.build();
range.setTextStyle(style);
(Sorry if its a bit messy, I dont know much about coding.. but want to learn :)
This is possible. Steps could be as follows -
Input ordernumber using a prompt
Search in Ads_sent_in
Search in Magazine_name_03-2019
If match, color cell/row
Question is simple. How to get Name (File name in Google Drive) of a spreadsheet using spreadsheet identifier. If you want to know why I need it, you may please continue reading further.
I have created two type of spreadsheets to manage my financial books with my friends, family and business.
Type 1: A book that contains all transactions with a specific person and tells Amount owed or amount lended. I have about 15 of such sheets. Check this screenshot:
Type 2: A sheet named as investments. It fetches data from all other sheets using Sheet Identifier and displays total amount invested or borrowed. Check this screenshot:
In Type 2 sheet, I have programmed and made everything automated. You just need to paste Identifier of any new Spreadsheet in G Column and you're done. Only one thing is Killing me. I am unable to fetch name of the spreadsheet using Identifier. I fetched all records of the sheet using IMPORTRANGE Method, just the file name is not getting fetched. I tried plenty of functions.
Yellow Columns denotes Automatic Columns. I just want to make Column B automatic in case of Type 2 Spreadsheet. It should contain Spreadsheet File Name fetched through Sheet Identifier, same as I fetched all rows of multiple sheets & made calculations within Type 2 sheet. Thanks for considering to help me out.
If I understood your question correctly, you want the name of a Sheets file from the Sheets ID? How about:
var spreadsheetId = 'YOUR_SPREADSHEET_ID';
var sheetName = SpreadsheetApp.openById(spreadsheetId).getName();