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
I want to use a specific range reference programmatically to sum (next 25 cells), for which I'm using OFFSET(), which requires a cell reference. However, most lookup functions return indexes, or values, not cell references, so I have to use INDEX().
I find it a bit ridiculous that I have to do this just to find the cell reference of a cell programatically:
INDEX(A:A, MATCH(C2, A:A, 0), 1)
Is there a better way to get a cell reference programmatically?
The whole thing looks like:
=SUM(OFFSET(INDEX(A:A, MATCH(C2, A:A, 0), 1), 0, 1, 25, 1))
You will want to utilize multiple Match() and their offsets... see:
=SUM(OFFSET(A1,MATCH(C2,A:A,0)-1,0):OFFSET(A1,MATCH(C2,A:A,0)+24,0))
Broken down:
First cell in your range to sum in column 1 (A), have to subtract 1 from it so you're using your actual match reference:
OFFSET(A1,MATCH(C2,A:A,0)-1,0)
Final cell in your range to sum in column 1 (A), have to subtract 1 from the desired offset (25) similar to the first cell:
OFFSET(A1,MATCH(C2,A:A,0)+24,0)
You can then sum between the offsets
It may seem ridiculous to you but the best non-volatile option is a pair of INDEX/MATCH functions that define the start and stop of your sum range in column B and dispense of OFFSET altogether.
=sum(INDEX(B:B, MATCH(C2, A:A, 0)):INDEX(B:B, MATCH(C2, A:A, 0)+24))
I have the following table and I'm trying to get a formula so that I can get the sum of a center's result between two dates i.e. Sum all numbers for Bunbury between dates 08-05-17 and 06-05-17 (Result: 950). I've used the following formula but it gives me #VALUE!
My formula:
=SUMIFS(INDEX(B:G,MATCH("Bunbury",$A15:$BC15,0),0),$A$16:$A$21,"<=" & $J3,$A$16:$A$21,">=" & $I3)
enter image description here
Your match should match the column, not the row in B:G.
=SUMIFS(INDEX($B$16:$G$21, 0, MATCH("Bunbury", $B$15:$G$15, 0)), $A$16:$A$21,"<="&$J3, $A$16:$A$21,">="&$I3)
'alternate
=SUMIFS(INDEX($B:$G, 0, MATCH("Bunbury", $B$15:$G$15, 0)), $A:$A,"<="&$J3, $A:$A,">="&$I3)
There's also no need to look further than column G for a match and you should start looking in column B; e.g. $B15:$G15. J3 should be the end date and I3 the start date (not evident from your sample image).
I missed one problem the first time around. INDEX cannot reference all of the rows in B:G; it can only reference the same number of rows as $A$16:$A$21 (the date comparison range). Alternately, if there is no rogue data that would skew results, the date comparison ranges could be made full column. They have to be comparable ranges.
I've been trying to write a formula to summarise in one cell the presence/ absence of certain values in a different range of of cells in Excel
So in the one table and worksheet, I wrote
=IF(B1:F1=1,1,0) Formula 1
which is supposed to mean
If any of the values in cells B1:F1 are equal to 1, then note 1, otherwise not 0.
But somehow the syntax isn't working.
I've applied "" and ; and brackets right left and centre, but to no avail.
I'm pretty sure I done this before and it was pretty simple when I hit upon the right synstax, but the how and where fell through the colander which is my brain today :-?
Additionally I will want to ask the formula to apply another condition to the output cell which is
=if (A1 = value n or certain values, 1, 0) Formula2
Column A has numerically coded ordinal values 0-9, so an aexample of teh 1 conditions might be any of values 1, 2 or 9 in column, should produce a 1 in the result cell in which Formula 1 and 2 will be written.
So the result cell would contain somelike
=Formula1_or_Formula2_contain_certain_values, 1, 0) Formula 3
Obviously the systax of Formulas 2 and 3 is awol, but I write to demonostrate the formulae intended purposes.
The easiest way to make the first formula is like this:
=IF(SUM(B1:E1)>0,1,0)
No arrays, no problems :)
Sorry if my title is confusing. I'm new to Logical formula in excel but I need it to achieve something now. I had check the internet for the formula but found it abit confusing and not sure what method i should use.
This is my situation:
I have an excel consists over 50+ rows. In each row, there are 5 different columns holding a value of either 1 or 0 with one extra column to determine the final value, which is something like below:
A1 = 0, B1 = 1, C1 = 0, D1 = 1, E1 = 1, F1 = (Final Value)
What I need is the logical statement to check if any cells from A1 to E1 consist of 0, then F1 will be equal to 0, else if all cells value is 1, then F1 is equal to 2.
As i said before, there over 50+ rows with the same thing, each line consists of 5 columns with a value of 1 or 0, and finally one extra column that hold the final value of 0 or 2 according to the 5 columns.
Kindly let me know any method i can use to achieve my needs or if there is any better solution to deal with all the rows which are basically the same thing.
Thank you for your time.
I like Gary's Student's for cleverness, but for clarity, I like:
=IF(COUNTIF(A1:E1,0)=0,2,0)
How about something like:
=MIN(A1:E1)*2