18.9 C
London
Friday, July 11, 2025
HomeSoftware TutorialsGoogle SheetsGoogle Sheets Query: How to Use Cell Reference in Formula

Google Sheets Query: How to Use Cell Reference in Formula

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

You can use the following basic syntax to use a cell reference in a Google Sheets query:

=QUERY($A$1:$B$11, "Select B where A contains '"&D3&"'")

In this particular query, we tell Google Sheets to select the value in column B where column A contains whatever value is in cell D3.

The following example shows how to use this syntax in practice.

Example: Use Cell Reference in Google Sheets Query

Suppose we have the following two datasets in Google Sheets:

Now suppose we’d like to add a ‘points’ column to the right of the ‘assists’ column, which contains the points scored by each team in column D.

We can use the following syntax to do so:

=QUERY($A$1:$B$11, "Select B where A contains '"&D3&"'")

The following screenshot shows how to use this formula in cell F2 of our spreadsheet:

In this example, we told Google Sheets to select the value in column B where column A contained the team name in cell D2.

In this case, it saw that D2 contained ‘Hornets’ so it returned the ‘points’ value for Hornets, which turned out to be 78.

We can then copy and paste this formula down to every remaining cell in column F:

Additional Resources

The following tutorials explain how to perform other common queries in Google Sheets:

Google Sheets Query: How to Select Multiple Columns
Google Sheets Query: Select Rows that Contain String
Google Sheets: How to Query From Another Sheet

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories