Can you create dynamic formulas in Google Sheets? - arrays

So I'm just starting out creating a portfolio tracker within Google Sheets. I'm using the Google Finance methods to get the stocks name and all the relevant data that I need. The only issue is that I can't figure out how to populate the specific data I need without having to manually type out the same formula's for each stock I want data for.
For example... Each row in the first column would contain the ticker symbol for that specific stock. If I bought a new stock, I would just type in the ticker symbol in cell A1 and this would populate the necessary fields such as price and so on. If I bought another stock I would essentially do the same thing but now in A2.
I know that you can get the price of a stock by doing
=GOOGLEFINANCE(A1, "price")
but is there any way to make it dynamic? something like:
=GOOGLEFINANCE(A(Row(ref)), "price")?
Any suggestions would be helpful. Maybe there's even an addon that makes this process simpler, but I'm not sure.

try:
=ARRAYFORMULA(IFERROR(GOOGLEFINANCE(A1:A10, "price")))

You just have to write the function for A1:
=GOOGLEFINANCE(A1, "price")
And then drag the little square on the cell down. It will automatically pick up the correspondant number of the row in the A column.
You can set-up your sheet to have like 100 rows used, and when you add the ticker it will automatically calculate it.
If you don't want th #N/A to show you can do it like:
=IFERROR(GOOGLEFINANCE(A1, "price"))

Related

what am i supposed to do in this situation?

so recently my principal is having me create a database for a tardy system recently what i've done is set up a google form where the student id can be enter through a num pad and put into a google sheet where ive setup 2 sheets one where it shows the student name and how many tardies they have and then the other is the google form responses, each tardies cell in the other sheet has the formula: =COUNTIF('Form Responses'!B:B,"") which essentialy checks the number of times a certain student id pops up, by ferpa i am not legally allowed access to the student id's is there any possible way i can maked it when a person enters their student id it adds/creates a new formula for the tardies cells to check through the entire list without a duplication or error code?
i have tried the =COUNTIF('Form Responses'!B:B,"") formula but that would make where my principal would have to edit a thousand lines of formula
Depending on the exact setup of your sheets, you can use a formula like this, guessing that the students' IDs are in A column:
=BYROW(A2:A,LAMBDA(each,IF(each="","",COUNTIF('Form Responses'!B:B,each))))
That would set a formula will drag all the column automatically.
Or, instead of having a list of IDs you can set a QUERY that will find all the ID values in the responses and their count:
=QUERY('Form Responses'!B:B,"SELECT B,Count(B) where B is not null group by B")

Excel Loop VBA to change cell value one master sheet

really need help on this. probably simple but im a novice so not so easy.
I have a work sheet, we'll call it masterdata. I gather my data form business 365 and paste multiple lines of data into the masterdata sheet. The lines basically consist of a PO number, a sales number, a part number, quantity and customer line number.
I use this data to generate QRCodes in a template on my first sheet named template. The QRcodes are generated by google then brought onto the sheet. (doesnt have to be google but i havent worked out how to get excel to do this without third party addons)
I have a macro split my data into individual sheets based on the PO number, each sheet could end up with 1 - 100 lines of sales data, each one referring to a separate PO number.
On my QRcode template sheet im using an indirect vlookup function to pull the data from each sheet based on the value entered into cell F2.
Can anyone help me automate this a bit as it can be quite time consuming entering the sheet number into F2, deleting the previous results QRCodes and refreshing the QRcodes then printing.
I'd like to auto cycle F2 with the names of each sheet one at a time, delete all QRCodes then refresh/download new QRcodes and print the page.
Is this even possible?
Thank you all in advance for taking the time to review my question.

Automatic filling of Stock price

I have a list of scrips of stock market. When I add a new scrip in a new row, I would like to automatically fill its current price using GoogleFinance function of google sheets.
In the attached google sheets, Column A contains the mnemonics of the scrip from which column B calculates the current price. When I add a new scrip, I copy the formula to the new row. How do I achieve it automatically?
GOOGLEFINANCE is already a type of ARRAYFORMULA so it is not supported under ARRAYFORMULA. this means that it is not possible to process your A column with one single formula. you have only two options how to do this:
use script which will detect new entry in A column and insert single-cell GOOGLEFINANCE formula adjacent to it
hardcode it like:
=IFERROR({GOOGLEFINANCE("NSE:"&A2);
GOOGLEFINANCE("NSE:"&A3);
GOOGLEFINANCE("NSE:"&A4);
GOOGLEFINANCE("NSE:"&A5);
GOOGLEFINANCE("NSE:"&A6);
GOOGLEFINANCE("NSE:"&A7);
GOOGLEFINANCE("NSE:"&A8);
GOOGLEFINANCE("NSE:"&A9)})

arrayforumla + sorting (googlesheets) sorting dynamic data

I'm using a googleform to collect info about game players and their scores for different games, and am trying to create a leaderboard.
I've used an ARRAYFORMULA in col A to bring back unique values of each Player, then another in col B to SUMIF their Scores. So it's a leaderboard, I want it to autosort by score descending.
I've tried using various scripts etc but it seems that even just using the Sort function doesn't work. It sorts for a second, then resets back to the order the Players appear on the Form Responses. I'm taking this to mean I can't sort dynamic data in this way.
Any ideas on how I can autosort this, so even when more Players are added it will always act as a leaderboard?
EDITED TO ADD LINK:
https://docs.google.com/spreadsheets/d/1oitJrH-TdeRFfHCCTf9XO2ma4qwN571cPkYJhhPKKi8/edit?usp=sharing
screenshot of googlesheet
try:
=QUERY(CombinedScores!A2:B, "order by B desc", )

How to solve Google sheets formula issue

Hoping someone here can help with a small issue.
I'm writing an array formula, which uses a vlookup to pull prices. Identical items can be either on the sales floor, or in various overstock locations, and since they gradually increase in value, only the price attached to the version thats on the sales floor should be valid. Vlookup unfortunately pulls the price for the first match it finds.
I've cannibalized the following code from various sources online, and it does work at pulling the correct prices, however, it appends "Sales floor" to every price.
Is there something I'm missing, or a way to further refine it?
={"Variant Price";if(Checkbox!B1=TRUE,Arrayformula(IFERROR(VLOOKUP(A2:A&"Sales Floor",Inventory!A2:K&Inventory!N2:N,Column(J2:J),false))),"")}
The variant price and checkbox portions are simply to add a title, and to be able to control whether the formula is activated, this sheet has a large number of formulas that don't need to run constantly.
try:
={"Variant Price"; IF(Checkbox!B1=TRUE,
ARRAYFORMULA(SUBSTITUTE(IFERROR(VLOOKUP(A2:A&"Sales Floor",
Inventory!A2:K&Inventory!N2:N,Column(J2:J), 0)), "Sales Floor", )))}

Resources