Apply VlLOOKUP till last non-empty row in google sheets - google-sheets

I have an automatically expanding google in which I am applying a Vlookup formula to extract values from another sheet matching the values from the main sheet.
This is the Vlookup formula-
=VLOOKUP(A2, IMPORTRANGE("1MNRMKGkC-c0COugUWpXOe5OxJXfmdXGboxAPhf5SaLA", "Sheet1!B3:E420"),4,0)
I want the formula to be auto applied to the new entries which get auto added in the main sheet. I used this formula I found on a website to apply this formula to the whole column also taking care of any empty cells in between.
=ArrayFormula(IF(ISBLANK(A2:A), "", VLOOKUP(A2:A, IMPORTRANGE("1MNRMKGkC-c0COugUWpXOe5OxJXfmdXGboxAPhf5SaLA", "Sheet1!B3:E420"),4,0)))
My problem is that after using this formula when a new entry is auto added to column A in the sheet, it gets added to 1001th row instead of the next non-empty row, because this formula is being applied to whole column.
Is there some way to apply the Vlookup to just be applied till last non-empty row, so that my next automatic entry gets added in the next empty row? Or any other alternative solution?
Thanks for the help!

try:
=ARRAYFORMULA(QUERY(IF(ISBLANK(A2:A),,VLOOKUP(A2:A,
IMPORTRANGE("1MNRMKGkC-c0COugUWpXOe5OxJXfmdXGboxAPhf5SaLA", "Sheet1!B3:E420"), 4, 0)),
"where Col1 is not null", 0))

Since we don't have sheet for reference assuming new data is added to new column.
Try this fromula =ARRAYFORMULA(If(A2:A="","",VLOOKUP(A2:A, IMPORTRANGE("1MNRMKGkC-c0COugUWpXOe5OxJXfmdXGboxAPhf5SaLA", "Sheet1!B3:E420"),4,0)))
This will do vlookup once there is new data in Column 'A'

Related

Google Sheets Conditional Formatting custom formula not working to same as in cells

So have an ArrarFormula in H5 that works exactly the way I want. It searched all the cells in column C and compares them to column A and returns TRUE when column C contains column A. The problem is that I want to move that formula to conditional formating. When I do that it only captures some of the cells, highlighted in Blue. Here is the formula.
=ARRAYFORMULA(IFNA( LEN(REGEXEXTRACT(C5:C, JOIN("|",QUERY(A5:A, "Select A where not A is null")))) > 0))
I have tried copy/pasting to conditional formatting and removing the ArrayFormula and the IFNA. I still get the same results. I know that I can just reference column H in conditional formatting, but I want to try to keep this as clean as possible.
Here is a link to the sheet. https://docs.google.com/spreadsheets/d/1xT_U_UZ27X724VAGwUjZ_6fHkE6IaegnbzQTC_kOfEg/edit?usp=sharing
I just modified your original formula so it can work with conditional formatting:
=IFNA( LEN(REGEXEXTRACT(C5, JOIN("|",QUERY($A$5:$A, "Select A where not A is null")))) > 0)
Remove array formula and just use C5, the conditional formatting will automatically adjust its row based on your selected Apply to range
You need to fix the range in your query() by locking its row and column using $
Output:

Arrayformula is expanding on the whole column besides the the referenced cell being blank through not(isblank)

What i want is that if someone fills in the google form with dog boarding, google sheets should find the value for that particular service and display. I am using the array formula, with a condition that if the row doesn't have any answer then keep it blank.
Besides that it is expanding to the whole column.
=arrayformula(if(not(isblank(I3:I)),index(Sheet2!$B$2:$E$5,match($I$3:$I,Sheet2!$A$2:$A$5,0),match($D$3:$D,Sheet2!$B$1:$E$1,0)),""))
try:
=ARRAYFORMULA(IF(I3:I="",,IF(NOT(ISBLANK(I3:I)), INDEX(Sheet2!B2:E5,
MATCH(I3:I, Sheet2!A2:A5, 0),
MATCH(D3:D, Sheet2!B1:E1, 0)), )))

Drag down the formula of IMPORTRANGE that changes the last value into increment value

I have an IMPORTRANGE formula in Google Sheets and want to apply it in the rest of the cells below. When I drag down the formula, it stays the same:
=importrange("1jhXCPi6RUf8MD7XoYgQsH-E0x768UtVxE3XY_kBrbkE","OCT!F2")
How can I drag a formula and have it automatically increment the value (OCT!F2 should be change into OCT!F3 up to OCT!F118)?
When I drag down this formula, I want it to be like this.
=importrange("1jhXCPi6RUf8MD7XoYgQsH-E0x768UtVxE3XY_kBrbkE","OCT!F3")
You may use row formula:
"OCT!F3" = "OCT!F" & row(A3)
You may also include the range in single importrange:
"OCT!F2:F500"
Be careful: importrange formulas may slow down your sheets.

How do I organize formulas to work with columns in google sheets

Hi so I'm trying to make a spreadsheet in Google Sheets that takes two numbers and subtracts them and then does it in the next row .
So example the formula in C1 would be "subtract(A1, B1)" in the first row. But then in the next row I would like it to change to "subtract(A2, B2)" and output in C2.
(Without having to go in each C cell and change the formula of course)
So how do I do that and also how do I apply a formula to multiple cells of a row (C1,C2,C3,C4,C5, etc....)
Just put =MINUS(A1,B1) into C1 and then copy it and paste it in the remain rows of column C and the spreadsheet automatically adjusts the row numbers for you.
#Cooper's Answer above is perfect. I'm just giving a alternative here using array formulas, because it's easy.
Put this in D2
=ARRAYFORMULA(MINUS ( B2:B, MULTIPLY( 2.5, QUOTIENT(C2:C,15))))

How to use index match formula that automatically expands in Google Sheets

In Google Sheets I am using a filter function to pull in Names into column A and a Timestamp into column B. Every time a second occurrence of the name shows up into columns A & B of the list I want column C next to the prior occurrence to reference the new timestamp. In column D I will then calculate the difference from the names timestamp and the next occurrence of that same name.
Currently I am using the following formula:
=IFERROR(INDEX(B3:B,MATCH(A2,A3:A,0)))
If I drag this formula down it does what I need it to do, but due to how many rows are being added to the first two columns, rows are being added to the bottom of the sheet due to the filter and the formulas keep needing to be dragged down. The durations in column D are being calculated with the following formula, that automatically arrays the results and automatically expands with the filter results:
=IFERROR(ARRAYFORMULA(IF(C2:C="","",C2:C-B2:B)))
I would like my index match formula to do the same, but it seems I cannot use the index formula with an arrayformula.
I attempted to achieve this by using a vlookup combined with an offset for the range. The first row is giving me the result I want, but all the subsequent rows are not referencing the offset range, probably because the offset isn't changing with each new array result here is that attempt:
=IFERROR(ARRAYFORMULA(VLOOKUP(A2:A,OFFSET(A2:B,1,0),2,FALSE)))
Any ideas how this could be accomplished by placing a formula in one cell, or would this have to be accomplished with a script?
I have added an example spreadsheet of the current method HERE
Thanks in advance for any help.
Formula
Instead of
INDEX, MATCH and OFFSET
try the following formula
=ArrayFormula(IFERROR(VLOOKUP(
TRANSPOSE(VALUE(REGEXEXTRACT(QUERY(TRANSPOSE(
IF(FILTER(ROW(A2:A),LEN(A2:A))<TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
IF(FILTER(A2:A,LEN(A2:A))=TRANSPOSE(FILTER(A2:A,LEN(A2:A))),
TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
),)
),,2000000),"(\d+)"))),
FILTER({ROW(A2:A),B2:B},LEN(A2:A)),2,0)))
Formula description
This part creates a square matrix showing the row number of the value that matches if it's below of the current row:
IF(FILTER(ROW(A2:A),LEN(A2:A))<TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
IF(FILTER(A2:A,LEN(A2:A))=TRANSPOSE(FILTER(A2:A,LEN(A2:A))),
TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
),)
This part takes the smallest row that matches the current row (the next occurrence of the row value)
TRANSPOSE(VALUE(REGEXEXTRACT(QUERY(TRANSPOSE( ),,2000000),"(\d+)")))
This part returns the related value, if any, otherwise a blank:
IFERROR(VLOOKUP( ,FILTER({ROW(A2:A),B2:B},LEN(A2:A)),2,0)))

Resources