I want to change the cell address to string/text. For example :
AB123 --> "AB123"
I want to use it with indirect(), for example to refer to A1:A100 where the '100' is fetched from cell X1 -->
indirect( to_string( A1 ) & ":A" & X1 )
I didn't do indirect("A1:A"&X1) because since "A1" is static string so when i insert a new row on the very top so to shift down row 1, then the formula won't update automatically and will still refer to A1:A100 , in fact it should now refer to A2:A100 after the row insert. In this case i want to keep the A1 not as string so after insert it should updated to A2
What is the simplest way to do it?
Try this:
=cell("address", AB123)
This (or something like it) might also work instead of all that "indirect" stuff.
OFFSET is very good at defining changing ranges like that.
=OFFSET(A2,,,X1,1)
try:
=INDIRECT(ADDRESS(123, COLUMN(AB1)))
or:
=INDIRECT(ADDRESS(123, 28))
to get range AB123
I need to combine multiple cells in Google Sheets and have it autofill as new rows are populated. I tried using the ARRAYFORMULA, however it does not update the new cell reference. It only copy/pastes the first row formula and applies to the rest of the rows. Please see attached image for reference.
So I need to combine columns B, C & D in column A, while the formula in column A should dynamically reference the new row. Here's the formula used:
=ARRAYFORMULA(IF(ISBLANK(B:B),"",IF (B:B <> "",concatenate(text(B1,"yyyy-mm-dd") & C1 & D1 & E1),"COMBO")))
In the formula above, is there a way for values B1, C1, D1 to dynamically update to C2,D2, etc,...?
Thanks!
Just like mentioned in the comments, you can use FILTER and use this formula
=FILTER(TEXT(B:B,"yyyy-mm-dd") & "" & C:C & "" & D:D & "" & E:E,B:B<>"")
Furthermore, you can read more about the FILTER function by checking this link:
FILTER Google Sheets;
previous answer can be simplified to just:
=FILTER(TEXT(B:B, "yyyy-mm-dd")&C:C&D:D&E:E, B:B<>"")
otherwise, if you want to use your formula:
=ARRAYFORMULA(IF(B1:B="",,TEXT(B1:B, "yyyy-mm-dd")&C1&D1&E1, "COMBO")))
or:
=ARRAYFORMULA(IF(B1:B="",,TEXT(B1, "yyyy-mm-dd")&C1:C&D1:D&E1:E, "COMBO")))
or:
=ARRAYFORMULA(IF(B1:B="",,TEXT(B1:B, "yyyy-mm-dd")&C1:C&D1:D&E1:E, "COMBO")))
or:
=ARRAYFORMULA(IF(B1:B="",,TEXT(B1, "yyyy-mm-dd")&C1&D1&E1, "COMBO")))
I am in need of a sum of a completed values present in between two separate dates using Query function. My sheets are as follows. The first sheet name is "Sheet1" & The 2nd sheet name is "Sheet2". I need the count(SUM) of India completed values in the cell Sheet2!A2 within the date range of Cell A1 & Cell A2. For this, I was trying with the below Query function. But it didn't work out. Can anyone please help me here to get this data.
You need to use the below formula there
=sum(query(Sheet1!$A$1:$D$13,"Select 1 where D='India' and A>=date '" & TEXT(A1,"yyyy-mm-dd") & "' and A<= date '" & TEXT(B1,"yyyy-mm-dd") &"'",1),0)
I have some excel sheets with calculated fields, e.g. CELL_C =FIELD_A+FIELD_B. I need to extract all cells from that formula for highlight it with different color.
Is there any built-in VBA function to parse cell.Formula to get the range of cells?
You can always get the first-level precedents with something like:
Sub qwerty()
Dim rng As Range
Set rng = ActiveCell.Precedents
If rng Is Nothing Then
Else
MsgBox rng.Address(0, 0)
End If
End Sub
For example:
I'm having trouble figuring out a fairly simple QUERY statement in Google Spreadsheets. I'm trying to use a cell reference instead of static values and I'm running into trouble. Below it the code I'm using, but I keep getting a "Error: Formula parse error."
=QUERY(Responses!B1:I, "Select B where G contains"& $B1 &)
I'm sure it is a simple error, but can someone please show me how to write the above so the QUERY is pulling data from B where G contains the value in cell B1 (cell reference)?
Copied from Web Applications:
=QUERY(Responses!B1:I, "Select B where G contains '"&$B1&"'")
I only have a workaround here.
In this special case, I would use the FILTER function instead of QUERY:
=FILTER(Responses!B:B,Responses!G:G=B1)
Assuming that your data is on the "Responses" sheet, but your condition (cell reference) is in the actual sheet's B1 cell.
Hope it helps.
UPDATE:
After some search for the original question: The problem with your formula is definitely the second & sign which assumes that you would like to concatenate something more to your WHERE statement. Try to remove it. If it still doesn't work, then try this:
=QUERY(Responses!B1:I, "Select B where G matches '^.\*($" & B1 & ").\*$'") - I have not tried it, but it helped in another post: Query with range of values for WHERE clause?
I know this is an old thread but I had the same question as the OP and found the answer:
You are nearly there, the way you can include cell references in query language is to wrap the entire thing in speech marks. Because the whole query is written in speech marks you will need to alternate between ' and " as shown below.
What you would need is this:
=QUERY(Responses!B1:I, "Select B where G contains '"& B1 &"' ")
If you then wanted to refer to multiple cells you could add more like this
=QUERY(Responses!B1:I, "Select B where G contains '"& B1 &"' and G contains '"& B2 &"' ")
The above would filter down your results further based on the contents of B1 and B2.
I found out that single quote > double quote > wrapped in ampersands did work. So, for me it looks like this:
=QUERY('Youth Conference Registration'!C:Y,"select C where Y = '"&A1&"'", 0)
Here is working code:
=QUERY(Sheet1!$A1:$B581, "select B where A = '"&A1&"'")
In this scenario I needed the interval to stay fixed and the reference value to change when I drag it.
none of the above answers worked for me. This one did:
=QUERY(Copy!A1:AP, "select AP, E, F, AO where AP="&E1&" ",1)
To make it work with both text and numbers:
Exact match:
=query(D:E,"select * where D like '"&C1&"'", 0)
Convert search string to lowercase:
=query(D:E,"select * where D like lower('"&C1&"')", 0)
Convert to lowercase and contain part of the search string:
=query(D:E,"select * where D like lower('%"&C1&"%')", 0)
A1 = query/formula
yellow / A:B = result area
green / C1 = search area
blue / D:E = data area
If you get error when the input is text and not numbers; move the data and delete the (now empty) columns. Then move the data back.
Old Thread but I found this on my journey to the below answer and figure someone else might need it too.
=IFERROR(ArrayFormula(query(index(Sheet3!A:C&""),"select* Where Col1="""&B1&""" ")), ARRAYFORMULA({"* *","no cells","match"}));
Here is a simply built text Filter from a 3 column data set (A,B and C) located in "sheet3" into the current sheet and calling a comparison to a cell from the current sheet to filter within Col1(A).
This bit is just to get rid of the #N/A error if the filter turns up no results //ARRAYFORMULA({"* *","no cells","match"}))
Your question-title is very broad despite the question-body is asking for only one type of 'cell reference'. I'll try to answer some of the other scenarios in case other people come here looking for them.
A - String comparison with cell reference
=TRANSPOSE(QUERY(MIX!A16:F, "SELECT B,C,D,E,F WHERE (UPPER(A) = '"&F1&"') "))
=QUERY(MIX!A16:F, "SELECT B,C,D,E,F WHERE (UPPER(A) = '"&F1&"') ")
F1 = StringToSearch
B - String comparison with cell reference + SheetName is called using cell reference + Dates comparison using cell reference
F6 = SheetName
F2 and F3 = StringToSearch
I4 and I5 = dates with this format = 2022-01-01 = yyyy-mm-dd
If the dates you have are in a different format, you can use the formula below to convert them
I4 = TEXT(H5,"yyyy-mm-dd")
=QUERY(INDIRECT(F6&"!A2:C") , "select A,B,C where ((upper(B) contains '"&F2&"') or (upper(B) contains '"&F3&"')) AND (A >= date '"&I4&"') AND (A <= date '"&I5&"') ")
C - Data to query comes completely using cell reference
B1 = Sheetname!Range = Sheet1!A1:C
A36 = stringToFind
=QUERY(INDIRECT($B$1),"SELECT * WHERE upper(B) CONTAINS upper('"&A36&"') ")
The "$" in $B$1 make the reference static for column and row, so if you copy/paste the CELL containing the formula (NOT the text of the formula), the A36 adapts accordingly, but B1 stays fixed.
D - Data to query comes completely using cell reference + String comparison using cell reference + Number comparison using cell reference
=QUERY(INDIRECT($B$1),"SELECT * WHERE upper(B) CONTAINS upper('"&A40&"') AND C > "&A41&" ")
B1 = Sheetname!Range = Sheet1!A1:C
A40 = stringToFind = blah
A41 = Number = 100
E - Nested query (query inside query) + String comparison using cell reference + Number comparison using cell reference, using LIMIT and OFFSET
=QUERY( transpose( query(IMPORT!$A$7:AAL,"select * where A contains '"&$C34&"' ")) ,"SELECT * LIMIT " & $A34 & " OFFSET " & $B34, 0 )
The final '0' is there to NOT include the header in the results.