Vlookup and match - excel

I'm trying to cross data to fill a sheet but I'm having some doubts.
I have a number a value in a sheet, and I want to complete it with data from another sheet.
For example:
I want to complete Column C in sheet 1, with the age that appears in sheet 2 (no problem if it copy's the whole cell), but it's not in a specific column. I tried to use vlookup & match, and it's returning an error. a Vlookup the EAN column, and use match the specific string "Age:".
Can you help me? Am I using the right formula

Step 1, find the row you want to work on: (Match on values in Column A)
=MATCH(Sheet1!$A2, Sheet2!$A:$A, 0)
Step 2, grab that entire row via OFFSET or INDEX:
=OFFSET(Sheet2!$1:$1, MATCH(Sheet1!$A2, Sheet2!$A:$A, 0) - 1, 0)
Step 3, find the Age cell in that Row using HLOOKUP and Wildcards ("*"):
=HLOOKUP("Age:*", OFFSET(Sheet2!$1:$1, MATCH(Sheet1!$A2, Sheet2!$A:$A, 0) - 1, 0), 1, FALSE)
(Optional) Step 4, convert to number:
=0 + TRIM(SUBSTITUTE(HLOOKUP("Age:*", OFFSET(Sheet2!$1:$1, MATCH(Sheet1!$A2, Sheet2!$A:$A, 0) - 1, 0), 1, FALSE), "Age:", ""))
Then just drag that down from C2 to however many rows you need. This will find the cell that starts with "Age:" in any column, A:XFD

Edit:
Found this source where it explains how to do It. In your case it would be:
{=INDEX(Sheet 2!E2:CT2,MATCH(FALSE,ISBLANK(Sheet 2!E2:CT2),0))}
This is if your data starts on Row 2 and as you said the age columns are between E:CT
Note how to insert the array formula as is explained on the post of the source.

Related

How to SUMIFS horizontally with a criteria and offset

I'm having trouble with an excel formula where i'm trying to get the sum of all numbers in the row which are at 1 column offset with the criteria.
Eg. A1 = Price | B1 = $1000| C1 = Price| D1 = $1500 and so on....
Answer should be 1000+1500= $2500
I tried =SUMIF(1:1,"Price",OFFSET(1:1,0,1)) but gives me error!
I am guessing you have the cell with your formula in the same row, so it is a cyclic reference that gives you the error.
You can cut 1:1 before the cell with the SUMIF:
=SUMIF(OFFSET(1:1, 0, 0, 1, COLUMN() - 2), "Price", OFFSET(1:1, 0, 1, 1, COLUMN() - 2))
a possible solution is to offset your reference ranges. This means you will not be able to do an entire row reference. In your limited example your formula would wind up looking like this:
=SUMIF(A1:Q1,"price",B1:R1)
so you sum range will be limited to one less column than what is available to the sheet to allow for the second range (equal in size range) to be shifted one column to the right.
SIDE NOTE
Idealy you would want to arrange your data in a table. I understand this may not always be possible when dealing with 3rd party data dumps, limited VBA knowledge, and large amounts of data.
SUMIF(A20:ZZ20, "Price", OFFSET(20:20, 0, 1, 1, COLUMN() - 2))

Merge two columns into one column, one cell after another

I am trying to merge two columns into one column, one cell after another. For example, I have start time in one column and End time into another column, shown in pic. I am trying to merge them into one column (Time) that has start time in one cell and end time in the cell just below it, with duplicating the code (the third column) with each addition. Like shown in the pic.
Is there a way to do that?
Forwards:
Formula in D2:
=INDEX($A$2:$B$9,ROUND(ROW(A1)/2,0),MOD(ROW(),2)+1)
Formula in E2:
=INDEX($C$2:$C$9,ROUND(ROW(A1)/2,0))
Backwards:
Formula in D2:
=INDEX($A$2:$B$9,ROUND(((COUNTA(C:C)-1)*2-(ROW(A1)-1))/2,0),MOD(ROW(A1),2)+1)
Formula in E2:
=INDEX($C$2:$C$9,ROUND(((COUNTA(C:C)-1)*2-(ROW(A1)-1))/2,0))
This is the forumula I would use:
=CHOOSE(SEQUENCE(,2),INDEX(A1:B8,(SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0)-MOD(SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0),COLUMNS(A1:B8)))/COLUMNS(A1:B8)+1,MOD(SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0),COLUMNS(A1:B8))+1),INDEX(C1:C8,(SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0)-MOD(SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0),COLUMNS(A1:B8)))/COLUMNS(A1:B8)+1))
But that formula is a bit messy, so, I wrote another one that breaks down the formula in a way that I can talk through how it works and what its doing:
=LET(
TimeRange,A1:B8,
CodeRange,C1:C8,
RowCount,ROWS(TimeRange),
ColumnCount,COLUMNS(TimeRange),
CellCount,RowCount*ColumnCount,
BaseSequence,SEQUENCE(CellCount,,0),
ModSequence,MOD(BaseSequence,ColumnCount),
RowIndex,(BaseSequence-ModSequence)/ColumnCount+1,
ColumnIndex,ModSequence+1,
Result1,
INDEX(TimeRange,RowIndex,ColumnIndex),
Result2,
INDEX(CodeRange,RowIndex),
CHOOSE(SEQUENCE(,2),Result1,Result2)
)
If you want to paste this formula into your spreadsheet, just make sure that you have the formula bar selected. If you don't, Excel will paste the text so that each line break moves to the next row.
What does each part do? This table steps through each parameter, and explains what each one does. And yes, when using a LET statement, you can use variable names declared in the prior step, but you can't do it the other way!
Part
Explanation
LET(
LET basically allows us to name our own variables. You'll see what I mean in the following sections
TimeRange, B11#
This is the StartTime and EndTime Ranges from your example
CodeRange, D11#
This is the Code range from your example
RowCount, ROWS(TimeRange)
This gives us the number of rows in TimeRange, and stores it as RowCount
ColumnCount, COLUMNS(TimeRange)
This gives us the number of columns in TimeRange, and stores it as RowCount
CellCount, RowCount*ColumnCount
This calculates how many cells there are. Note that our answer will have rows equal to CellCount
BaseSequence, SEQUENCE(CellCount,,0)
This creates a sequence of numbers, arranged in a single column, starting at 0, and stores the result in BaseSequence
ModSequence, MOD(BaseSequence, ColumnCount)
Here, we take the MOD of BaseSequence, by ColumnCount. Why? Because this effectively gives us a list of numbers counting up from 0 to 1. Note that this is why BaseSequence had to start at 0
RowIndex, (BaseSequence - ModSequence)/ColumnCount + 1
This basically counts through the rows, giving us 1, 1, 2, 2, 3, 3, (etc)
ColumnIndex, ModSequence + 1
Because unlike MOD, which starts at 0, column and row indices start at 1
Result1, INDEX(TimeRange, RowIndex, ColumnIndex)
This is our left hand column, and basically picks through the TimeRange, going through each row by picking up each column first
Result2, INDEX(CodeRange, RowIndex)
This is our right hand column, and it basically doubles up each element in the CodeRange (i.e. teacher, teacher, student, etc), because RowIndex runs 1, 1, 2, 2, 3…
CHOOSE(SEQUENCE(,2),Result1, Result2)
The last item in a LET statement is the one that returns a value to the spreadsheet. Here, I'm using a SEQUENCE to make a range 1 row and ColumnCount columns wide (i.e. [1, 2]). This goes into CHOOSE, which will select Result1 when it gets a 1, and Result2 when it gets a 2. Because both Result1 and Result2 are ranges, CHOOSE effectively combines them into a single Range
Also, in the event you want it, this is the formula I posted first (at the top), but with additional line breaks to improve legibility:
=CHOOSE(
SEQUENCE(,2),
INDEX(
A1:B8,
(
SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0)
-MOD(SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0),COLUMNS(A1:B8))
)
/COLUMNS(A1:B8)+1,
MOD(SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0),COLUMNS(A1:B8))+1
),
INDEX(
C1:C8,
(
SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0)
-MOD(SEQUENCE(ROWS(A1:B8)*COLUMNS(A1:B8),,0),COLUMNS(A1:B8))
)
/COLUMNS(A1:B8)+1
)
)
Assuming your data starts in row 2.
=A2&" "&B2

Returning value of cell adjacent to INDEX MATCH

Is there any way to get the cell next to an INDEX MATCH? E.g., if the cells are laid out at such:
A B
n Name Bob
n+1 Location Canada
n+2 StartDate 23/06/2018
n+3 StartTime 2:03:19 PM
n+4 Mode Frequency
I want to retrieve the StartDate, 23/06/2018. For the moment I've used
INDEX(Sheet1!A:A, MATCH("StartDate", Sheet1!A:A, 0))
to find the string "StartDate" (the row number may vary), but then how do I access the actual date, 23/06/2018?
Easy way:
INDEX(Sheet1!A:B, MATCH("StartDate", Sheet1!A:A, 0), 2)
Note the 2 is indicating the second column of the range "A:B" - you could instead INDEX over the range "B:B" instead:
INDEX(Sheet1!B:B, MATCH("StartDate", Sheet1!A:A, 0))
Better way: I often find myself taking one of the following two approaches (though these are overkill if you are doing a one-off formula):
INDEX MATCH:
Just like you have done, but match on column as well as row (the "B" bit is because you have "B" at the top of the column - this way you can find specific columns)
INDEX(Sheet1!A:B, MATCH("StartDate", Sheet1!A:A, 0), MATCH("B", Sheet1!1:1, 0))
OFFSET:
OFFSET(Sheet!$A$1, MATCH("StartDate", Sheet1!$A:$A, 0) - 1, MATCH("B", Sheet1!$1:$1, 0) - 1)

Updating values in cells excel

Please find attached screenshot of my Excel doubt.
As in the screenshot, I want to update the 3rd and 4th row values in the 2nd row, leaving those dates without any value.
In the screenshot it is shown that in the question part 3rd row dates with 5/17/1997 5/18/1997 does not have any values. So want to leave those cell blank and update the rest with the date and values in the 3rd and 4th row, leaving those dates without value for the rest of the cells. Kindly help me with any functions or formulas for doing this.
First step: copy paste Row 3 to Row 10.
Formula in AUE11:
= IFERROR( If(Match(AUE$10, $AUE$4:$AUV$4, 0) > 0, AUE$10, "") , "")
Formula in AUE12:
= If(AUE$11 <> "", Index($AUE$5:$AUV$5, 1, Match(AUE$10, $AUE$4:$AUV$4, 0)), "")
Remember to format Row 10 and 11 as Dates, otherwise you might get numbers as a result (e.g. 35562 instead of 5/12/1997). Also, adjust the range (AUE:AUV) to your actual range.

IF statement that will let me input values from a single cell

I need to look through column C and search for a text "TF06" and if that's true I need to replace the corresponding row in column D to the specific input FROM cell F2.
This is as far as I can get. Here is my code:
=IF((VLOOKUP("TF06", C2:D54, 2, FALSE)), REPLACE(ROWS(VLOOKUP("TF06", C2:D54, 2, FALSE)), 1, 1, F2), 0)
This should work...if its always F2 change it to F$2 this should be in column D if thats where you want the data to go?
=IF(A3="tf06",F3,"")

Resources