Eron Falbo
Eron Falbo

Reputation: 21

Google Sheets Query referencing a cell's text

When I perform this function, it works:

=Query(CRM!1:1085,"Select B where D contains 'FirstName LastName' ",4)

When I perform this one, where B31 is where the text "FirstName LastName" is located in the sheet, the output is only ONE of the many results:

=Query(CRM!1:1085,"Select B where D contains '&B31&' ",4)

I want to be able to use the cell rather than write the quoted text in the formula. This is because I need to quickly replicate the formula for many different values. Also because it needs to be automated in case of changes in the source.

Upvotes: 1

Views: 16763

Answers (1)

TheMaster
TheMaster

Reputation: 50445

B31 is interpreted as literal string, when you use just 'B31'. You need to use double quotes along with single ones and concatenate:

'"&B31&"'

Upvotes: 7

Related Questions