In this article:

Import Yahoo Finance Data to Google Sheets (Easiest Way 2024)

In this article we will show how to import Yahoo Finance data to Google Sheets using a custom apps script. Simply follow the steps below.

Import Yahoo Finance Data into Google Sheets

1. Click Extensions then select Apps Script

We will use a custom script to import Yahoo Finance data to Google Sheets. Click Extensions in the main menu, then select Apps Script.

yahoo finance on google sheets, click extensions, select apps script

A new tab will appear where the Apps Script will be loaded. 

importing yahoo finance data into google sheets, apps script interface

2. Copy the Script to Apps Script

As you notice, the text area of the script holds some lines of placeholder code. Delete it by selecting them all and then pressing the Delete key in your keyboard. Next, copy and paste the following code: 

function yahooF(ticker) {

 const url = `https://finance.yahoo.com/quote/${ticker}?p=${ticker}`;

 const res = UrlFetchApp.fetch(url, {muteHttpExceptions: true});

 const contentText = res.getContentText();

 const price = contentText.match(/<fin-streamer(?:.*?)active="">(\d+[,]?[\d\.]+?)<\/fin-streamer>/);  console.log(price[1]);  return price[1];

}

The code is from Jason Hee’s article in Medium. Thank you!

Script for pulling yahoo finance data in google sheets

You can rename the project by clicking the box containing the words Untitled project. When you hover your cursor over it, a Rename label will appear. Click it.

yahoo finance google sheets, rename apps script project

A small pop-up box will appear where you can set the Project title. Once done, click Rename. 

yahoo finance google sheets, rename apps script project box

3. Save Project

After copying the script to Apps Script, save the code by clicking the Save project icon along the main toolbar. The icon is on the left of the Run button. 

Save project to import yahoo finance data into google sheets

After saving the code, the save icon will turn to gray instead of black.

Script to import data from yahoo finance to google sheets saved

4. Use Formula =yahooF(ticker) to Your Sheets

Go back to the sheet. Type the yahooF formula with the ticker (TSLA, AAPL, etc)  in double quotes. Google Sheets will initially notify you that yahooF is an unknown function. 

yahoo finance google sheets formula

Once you have set up the formula, click Enter. The script works! Our formula now displays the current price of the Nasdaq 100 (NQ=F).

Formula to get yahoo finance data in google sheets working

Use our email reminder software to set up custom reminders from your spreadsheet in just a few clicks. 

If you enjoyed this article, you might also like our article on how to import CoinMarketCap data into Google Sheets or our article on how to import Binance API in Google Sheets. 

If you want to learn how to extract domains from emails in Google Sheets, we also suggest checking out our detailed guide. 

Automate repetitive tasks with Lido

Save hours on repetitive and tedious work. Lido is a new spreadsheet that connects your spreadsheets, forms, PDFs, and email inbox.

Trigger
Action
Select trigger
When a cell value in Google Sheets changes
Check Google Sheets for today's date
When a new row is added to Google Sheets
On new Google Form submission
Send me a daily reminder
On new Typeform submission
When a cell value in database changes
Check database for today's date
When a new row is added in database
When a new HubSpot customer is created
Select action
ADDCALENDAREVENT
Creates a one- or multiple-day calendar event with optional attendees
ADDHUBSPOT
Adds an object to Hubspot
ADDSLACKCHANNEL
Create a Slack channel, and optionally add a topic or members
CALLURL
Makes any HTTP request
CREATEGOOGLEDOC
Replaces [@column_name] values in a Google Doc with the corresponding table row's values
CREATEPDF
Replaces [@column_name] values in a Google Doc with the corresponding table row's values, then export it as a PDF
FETCH
Makes any HTTP request and returns the response
INSERTROWS
Inserts given array below defined values in given worksheet
SENDGMAIL
Sends an email using your Google account
SENDOUTLOOK
Sends an email using your Microsoft Outlook account
SENDSLACK
Sends a Slack message
SENDSMS
Sends an SMS message using your Twilio account
UPDATECELL
Updates cells with given values
UPDATEHUBSPOT
Updates a property of a Hubspot object
Trigger is required
Action is required
Get started