In this article:

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

May 8, 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

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. 

Get Google Sheets productivity and automation tips delivered straight to your inbox
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
We'll email you 1-3 times a week — and never share your information.
Get your copy of our free Google Sheets automation guide!
  • 27 pages of Google Sheets tips and tricks to save time
  • Covers pivot tables and other advanced topics
  • 100% free

Work less, automate more!

Use Lido to connect your spreadsheets to email, Slack, calendars, and more to automate data transfers and eliminate manual copying and pasting. View all use cases ->