Seamus Clarke
Seamus Clarke

Reputation: 35

Use cell number in cell reference in query

I have this formula:

=query(A6:D848,"Select * where D LIKE'"&AC1&"' AND A <> 'Grand Total'",0)

Where AC1 has a value of 2 in it.

The above works a treat, but when I try to change the LIKE to a >, I get an error.

=query(A6:D848,"Select * where D >'"&AC1&"' AND A <> 'Grand Total'",0)

I'm assuming that it's because referencing a cell value gives back a string value an not an number, but I can't figure out how to get it to change to an number and make the query work.

Upvotes: 1

Views: 97

Answers (1)

ZygD
ZygD

Reputation: 24386

=query(A6:D848,"Select * where D > "&AC1&" AND A <> 'Grand Total'",0)

You received the error, because you had several quotes there.
'"&AC1&"' = ' + " + &AC1& + " + '
You needed to remove the single quotes, because those were required for LIKE and not needed for >.

Upvotes: 2

Related Questions