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

4 Minutes

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 = `${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

Tired of constantly monitoring your spreadsheets? Scale operations with Lido automations and free up time to focus on what really matters.