Shifting Bounds of an excel array by an arbitrary number of columns - excel

I want to change the left bound of an array by an arbitrary amount of columns. for example i have the range A4:AA4. I want to shift the left bound of the array to D4:AA4. The number of columns that i shift the array by is arbitrary. So it could be D4:AA4, E4:AA4, F4:AA4 ...etc
I want to be able to do this in a formula, not through VBA. I want to use this range INSIDE a =MATCH() function. Could anyone help me out with this? thanks!

Not sure exactly what you are trying to accomplish here. Are you just looking for an absolute cell reference in your formulas? In case you are consider the following:
A B C
2 5 3
3 6
4 7
5 8
6 9
7 10
8 11
9 12
Column A contains the numbers 1 - 9
In B1 i type in the following formula =SUM(A1+$C$1) which i then autofilled until B8.
The dollar sign makes the both the column and row reference absolute and will not shift as part of the autofill.
If this is way of the mark so you have another way of explaining it or maybe included some sample data and desired output.

Related

Move the value of all cells in a column to their corresponding excel row number

Let's say i have the below list of Whole numbers in Column A. If you observe the list of numbers, you will see that number "5" and 6 is missing.
A
3
2
4
1
7
8
what I want to achieve is to place (sort) the numbers on the column such that each cell value will take its position according to excel row numbering. which means:
I should have something like this
1
2
3
4
7
If it's as simple as stated, this should work.
In column B, say:
=IF(COUNTIF(A:A,ROW())>0,ROW(),"")
Note: It does not account for duplicates, or anything complicated really.
Further Note: To clarify, all this does is check if the row that the formula is in, is in column A. If it is, then it returns the current row.

Excel formula - Get the sum of each variable every 6 days

I have the following dataset where I want to get the sum of each variable every 6 days. I can get the total sum of every 6 days using
=SUM(OFFSET($A$2,,(COLUMNS($A$5:A5)-1)*6,,6))
And I can get the total sum of each variable using
=SUMIF(A1:S1,A1,A2:S2)
But I cant get the total sum of each variable within the block of 6 days. It won't increment when I drag the formula.
So the results should be
First batch Second batch Third batch
A B C A B C A B C
2 2 2 4 4 4 6 6 6
You can use SUMPRODUCT:
=SUMPRODUCT((1:1=A6)*2:2*(COLUMN(1:1)>(INT((COLUMN()-1)/3)*6))*(COLUMN(1:1)<=(INT((COLUMN()-1)/3+1)*6)))
Edit:
To shift the column by five position, you will need to change the following parameters in the formula:
Full row range change to exact range, i.e. 1:1 to e.g. $F$1:$W$1
Change COLUMN()-1 to COLUMN()-3
If you also want to change the number of columns to be summed, additionally replace the factor of 6 with a 7-1 for seven columns or 36-30 for thirty-six columns.
So formulas looks like:
batch of 6 cols
=SUMPRODUCT(($F$1:$W$1=F6)*$F$2:$W$2*(COLUMN($F$1:$W$1)>=((INT((COLUMN()-3)/3))*6))*(COLUMN($F$1:$W$1)<((INT((COLUMN()-3)/3+1))*6)))
batch of 7 cols
=SUMPRODUCT(($F$1:$Z$1=F6)*$F$2:$Z$2*(COLUMN($F$1:$Z$1)>=((INT((COLUMN()-3)/3))*7-1))*(COLUMN($F$1:$Z$1)<((INT((COLUMN()-3)/3+1))*7-1)))
batch of 36 cols
=SUMPRODUCT(($F$1:$WW$1=F6)*$F$2:$WW$2*(COLUMN($F$1:$WW$1)>=((INT((COLUMN()-3)/3))*36-30))*(COLUMN($F$1:$WW$1)<((INT((COLUMN()-3)/3+1))*36-30)))
Instead of creating a really, really, really complex formula that can be dragged right, I suggest you add a row to the data at the top that identifies the batch number. Then you can use that batch number as an additional parameter in the Sumifs(). you can hide the rows with the batch numbers if they upset your spreadsheet design.
=SUMIFS(3:3,1:1,A16,2:2,A17)
This is far easier than creating a formula that dynamically adjusts references in tiered steps of three and six.

How to create two columns that match all values from a third in excel or OpenOffice?

I have one column with 10 cells, every cell have a different value in it. How can I create two columns that have every cell matching with the other 9.
Example :
1
2
3
4
5
6
7
8
9
10
Become
1 2
1 3
1 4
1 5
......
2 1
2 3
2 4
2 5
.....
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
I am not sure I read the same question as others did. I think your example was merely that, an example, and that these first 10 cells could contain anything and you wanted every permutation that could result. While I think that the other answers might work for the specific situation you describe, they may not work if you had other data in those cells. Hence I am offering a variation which uses a similar technique to reference the cells indirectly. The permutations of 2 objects from a set of 10 unique objects would result in 90 objects (which is why the above technique from Tom Sharpe references 90).
Assuming that you have your 10 items in A1 through A10, I would put the following formula in B1 and copy it down through B90:
=INDIRECT("R"&QUOTIENT(ROW()-1,9)+1&"C1",FALSE)
Also, I would use this formula in C1 and copy it down through C90:
=INDIRECT("R"&MOD(ROW()-1,9)+1+((MOD(ROW()-1,9)+1)>=QUOTIENT(ROW()-1,9)+1)&"C1",FALSE)
The result should give you something like what is shown in the attached matching your example.
Likewise, it would show the permutations of any values you had in A1 through A10 as shown in the second attached picture with words instead of the numbers 1 through 10.
In Excel (without VBA or such like), one way:
In A1 and copied down to A100: =INT((ROW()+9)/10).
In B1 and copied down with Ctr to B10: 1.
Select B1:B10 and copy down with Ctrl to B100.
In C1 and copied down to C100: =A1=B1.
Select ColumnsA:B, Copy, Paste Special, Values.
Filter A:C ,select TRUE in ColumnC and delete all blue indexed (visible content) rows.
Delete ColumnC.
Or in A1:
=QUOTIENT(ROW()-1,9)+1
copied down to A90 just to be different.
Then in B1:
=MOD(ROW()-1,9)+1+((MOD(ROW()-1,9)+1)>=A1)
copied down to B90.

Flag rows contributing to the sum criteria

I have two columns like this:
Name Value
A 1
A 4
B 3
B 2
B 5
C 6
C 8
C 10
C 4
I am doing sumif based on Names but I have a criteria to full fill. Looking from the least values in a name group whenever my sum reaches lets say 5 I want those rows to have a flag 1 or else 0. In this example it should be:
Name Value Flag
A 1 1
A 4 1
B 3 1
B 2 1
B 5 0
C 6 0
C 8 0
C 10 0
C 4 1
The data is random and not in any order and file is dynamic so can not work around by just putting it in decreasing order. I do not have any idea about offset. Could it be done without using offset and only by regular ifs, sumifs etc. Thanks a tonn!
Perhaps this can be simplified somewhat, though, assuming you put your chosen threshold (e.g. 5) in J1 and that, as implied by your reply to my last comment, no one value for a given Name occurs more than once, then, in C2, array formula**:
=IFERROR(GESTEP(MATCH(1,0/(MMULT(0+(ROW(INDEX(A:A,1):INDEX(A:A,COUNTIF(A$2:A$10,A2)))>=TRANSPOSE(ROW(INDEX(A:A,1):INDEX(A:A,COUNTIF(A$2:A$10,A2))))),SMALL(IF(A$2:A$10=A2,B$2:B$10),ROW(INDEX(A:A,1):INDEX(A:A,COUNTIF(A$2:A$10,A2)))))<=J$1)),MATCH(B2,SMALL(IF(A$2:A$10=A2,B$2:B$10),ROW(INDEX(A:A,1):INDEX(A:A,COUNTIF(A$2:A$10,A2)))))),0)
Copy down as required.
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
In column C add
=IF($B10<5,1,0)
Im assuming the last value is meant to be 0 as the values in C have already passed 5? Try this one.
=IF(SUM(A2:INDEX($B$2:$B$10,MATCH(A2,$A$2:$A$10,0)))<6,1,0)

Excel - find a value in two dimensions

I have a table of data like this:
a b c d
1 1 2 3 4
2 5 6 7 8
3 9 10 11 12
4 13 14 15 16
And I want a formula that finds the maximum value (16) and return its row number (4 in this case). How do I do that?
INDEX(a1:d1,MATCH(MAX(a1:h4),a1:h4,0),) ain't working :(
Sheet layout:
B1:E1: column headers
A2: A5: row headers
B2:E5: data
Array formula:
{MAX(IF(B2:E5=MAX(B2:E5);ROW(B2:E5)-1;""}
As the question asked for "d" as a result initially, the corresponding array formula is below:
{=OFFSET(A1;MAX(IF(B2:E5=MAX(B2:E5);ROW(B2:E5)-1;""));0)}
Shift-Ctrl-Enter to in a formula window to insert. Curled brackets are inserted by Excel,not by a user.
And one more humble girl's opinion:
=ADDRESS(ROW(OFFSET(A1,MAX(IF(B2:E5=MAX(B2:E5),ROW(B2:E5)-1,"")),0)),COLUMN(OFFSET(A1,0,MAX(IF(B2:E5=MAX(B2:E5),COLUMN(B2:E5)-1,"")))),4) - but entered as ARRAY formula via Ctrl+Shift+Enter, will return E5 (assuming #Jüri Ruut regions), which is simply the address of the desired cell.
Hope this attached screenshot is self explanatory?
Ok, I would program a macro like that:
Iterate over each row - find the maximum for that row.
Store the value in a array and than compute the maximum again.
Probably it would work with formulas too. Simply compute the maximum of each row in a seperate column and THEN compute the maximum of that column.
Try this array formula
=MIN(IF(A1:H4=MAX(A1:H4),ROW(A1:H4)))
confirmed with CTRL+SHIFT+ENTER
if there are multiple occurrences of the MAX value in A1:H4 then the formula will give you the first row in which it occurs

Resources