Excel Autofill nth cell value in left direction - excel

These are the cells I have
T
1
2
3
H
1
2
3
A
1
2
3
N
1
2
3
I am trying to use autofill to fill in left direction order
N
A
H
T
When I get K,1,2,3 in the first table,
I just want to insert a cell in the very left side of the second table, drag, and automatically fill in the cell with K, and so on.
Any idea for nth cell autofill data in left direction order in Excel?

My results are here..
=LET(a,B1:Q1,b,TEXTJOIN(,,IF(ISTEXT(a),a,"")),MID(b,SEQUENCE(,LEN(b),LEN(b),-1),1))
=MID(TEXTJOIN(,,IF(ISTEXT(B1:Q1),B1:Q1,"")),SEQUENCE(,SUMPRODUCT(--ISTEXT(B1:Q1)),SUMPRODUCT(--ISTEXT(B1:Q1)),-1),1)

Using the character identification number, you can add or subtract like classic numbers and display a sequence of orthographic characters.
From your first cell, example "A" in A1
Write instead of your second cell example "B" in E1, replace "B" with: =CHAR(CODE(A1) + 1)
Then take your 3 cells : B | 1 | 2 | 3 and stretch your selection, if you don't want to increment the numbers, select "copy cells" and your letter sequence will be done automatically.
Finally it's look like that :
If you need a character break such as A | D | G you can do + 3 instead of + 1
*Ps : CHAR is for CHARACTER in English, if your Excel is in another language, this formula can change for example CAR for French version.
Have a good cells !

Assuming you are looking only for capital letters as per your sample data. You can try the following in cell R1:
=INDEX(A1:P1,SORT(TOROW(XMATCH(CHAR(ROW(65:90)), A1:P1),2),,-1,1))
or using LET to avoid repetition:
=LET(r, A1:P1, INDEX(r,SORT(TOROW(XMATCH(CHAR(ROW(65:90)), r),2),,-1,1)))
UPDATE: Taking the idea suggested by #Manoj's answer of using ISTEXT function, then it can be solved as follows:
=LET(r, A1:P1, f, FILTER(r, ISTEXT(r)), SORTBY(f,
SEQUENCE(,COLUMNS(f),COLUMNS(f),-1)))
It is more generic since it discriminates between numbers and letters.
Here is the output:

Related

count occurence of values individually and as a group in excel row

o/p is the required column which is how many times D and P occured in a row either individually or as a group i.e if D and P occurs continuously, it is counted as 1. I am pretty sure there must be a formula for this somewhere only it is difficult to phrase the right words to search it. Hence this question here. Looking for a formula that does the job.
Give the following a try, assuming it's either "U", "D" or "P":
Formula in A1:
=BYROW(B1:L4,LAMBDA(a,IFERROR(COLUMNS(TEXTSPLIT(CONCAT(a),"U",,1)),0)))
Above works for newest versions of Excel, for older CSE-required versions of Excel try:
=SUM(N(FREQUENCY(IF(B1:L1<>"U",COLUMN(B1:L1)),IF(B1:L1<>"U",0,COLUMN(B1:L1)))>0))
If U can be any text or character other than P or D then the following should work:
=LEN(TEXTJOIN("",1,0,MMULT({1,1},--({"D";"P"}=B2:L2))))-LEN(SUBSTITUTE(TEXTJOIN("",1,0,MMULT({1,1},--({"D";"P"}=B2:L2))),"01",2))
Or using Office 365 this spills the result:
=LET(t,BYROW(B2:L12,LAMBDA(b,TEXTJOIN("",1,0,MAP(b,LAMBDA(m,--(OR(m={"D";"P"}))))))),
DROP(REDUCE(0,t,LAMBDA(x,y,VSTACK(x,LEN(y)-LEN(SUBSTITUTE(y,"01",2))))),1))
Both formulas convert the cells to 0 (FALSE) or 1 (TRUE) if the cell equals P or D. The results of one row are joined with a leading 0 and SUBSTITUTE looks for each occurrence of 01 in given string and replaces these 2 characters by 1. If we then compare it to the stringlength prior to the substitute, we have the answer to your question.

Excel - formula to find how many cells to sum of N

I want to know how many cells it take to sum N. Please see following example:
number | cells to sum of 100
100 | 1
50 | 2
20 | 3
25 | 4
15 | 4
90 | 2
10 | 2
See the last column, it find the min number of current cell + previous cells to sum of 100.
Is there a way to do so?
Thanks.
In B2, array formula**:
=IFERROR(1+ROWS(A$2:A2)-MATCH(100,MMULT(TRANSPOSE(A$2:A2),0+(ROW(A$2:A2)>=TRANSPOSE(ROW(A$2:A2)))),-1),"Not Possible")
Copy down as required.
Change the hard-coded threshold value (100 here) as required.
As way of an explanation as to the part:
MMULT(TRANSPOSE(A$2:A2),0+(ROW(A$2:A2)>=TRANSPOSE(ROW(A$2:A2))))
using the data provided and taking the version of the above from B5, i.e.:
MMULT(TRANSPOSE(A$2:A5),0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5))))
the first part of which, i.e.:
TRANSPOSE(A$2:A5)
returns:
{100,50,20,25}
and the second part of which, i.e.:
0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5)))
resolves to:
0+({2;3;4;5}>=TRANSPOSE({2;3;4;5}))
i.e.:
0+({2;3;4;5}>={2,3,4,5})
which is:
0+{TRUE,FALSE,FALSE,FALSE;TRUE,TRUE,FALSE,FALSE;TRUE,TRUE,TRUE,FALSE;TRUE,TRUE,TRUE,TRUE})
which is:
{1,0,0,0;1,1,0,0;1,1,1,0;1,1,1,1}
An understanding of matrix multiplication will tell us that:
MMULT(TRANSPOSE(A$2:A5),0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5))))
which is here:
MMULT({100,50,20,25},{1,0,0,0;1,1,0,0;1,1,1,0;1,1,1,1})
is:
{195,95,45,25}
i.e. an array whose four elements are equivalent to, respectively:
=SUM(A2:A5)
=SUM(A3:A5)
=SUM(A4:A5)
=SUM(A5:A5)
Regards
**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).
I did the first 3 with an excel formula:
D3>100
C4 is where your numbers start, so C4=100, C5=50 etc.
Formula is on D4, D5, D6 etc
On D4:
=IF(C4>=D3;1;"False")
On D5:
=IF(C5>=D3;1;IF(C5+C4>=D3;2;"Error"))
On D6:
=IF(C6>=D3;1;IF(C6+C5>=D3;2;IF(C6+C5+C4>=D4;3;"Error")))
You can keep doing this, just keep replacing "Error" with an longer/updated version of IF(C6+C5+C4>=D4;3.
I don't know if this is the best way, but this will achieve it.
One way to solve this is to create an NxN matrix of equations instead of just a column. An example picture is provided. Columns E through I are hidden. The last column on the right determines the number required
Theoretically, you can also hard code the equations if the number of rows needed to get to 100 is a known small number. For example, if the number of rows is always four or less, C8 would be =IFS(B8>=100,1,SUM(B7:B8)>=100,2,SUM(B6:B8)>=100,3,SUM(B5:B8)>=100,4). BTW, you'll run into sum boundary problems with this equation on the first, second, and third rows. Therefore, the first row will need to be =if(B8>=100,1,""), the second row would be =IFS(B9>=100,1,SUM(B8:B9)>100,2,TRUE,"") and so on.

excel formula with "different" columns - not just a range

I try to do like this:
=COUNTIFS($AA:$AA;$AC:$AC;$AE:$AE;$AG:$AG;$AI:$AI;"yes")<1
Which is of course wrong.
What I would like to do is not use a range (like $AA:$AI) but instead use every second column in the formula source.
Possible or ?
Yes, this is possible with the following formula:
{=SUM(IF(AA:AI="yes";1;0)*IF(MOD(COLUMN(AA:AI);2)=0;1;1))<1}
Note, that this is an array formula. So, you need to press Ctrl + Shift + Enter. For more information on array formula read the following post: https://support.office.com/en-us/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7
The above formula counts all the occurrences of the word "yes" in the columns AA through AI. But each occurrence is furthermore multiplied with 1 or 0 depending on whether the column number can be divided by 2 without rest. Example:
Column AA is column 27. 27 divided by 2 equates to 13 with a remainder of 1. So, since there is a remainder, the second portion of the above formula (the second if) will return a 1 and not a 0. Hence, any occurrence of "yes" in column AA is accounted for. At the same time all occurrences in column AB will get multiplied with 0 (not accounted for). Since, I chose to use the divisor 2 all "yes" in every other column will be accounted for.
You can try this:
=COUNTIF(AA:AA,"yes") + COUNTIF(AC:AC,"yes") + COUNTIF(AE:AE,"yes") + COUNTIF(AG:AG,"yes") + COUNTIF(AI:AI,"yes")
See image for reference:

How to count distinct entries in a column in Excel

I know that the formula: {=SUM(1/COUNTIF(A1:A8,A1:A8))}
will work for counting the distinct entries in the column A1 to A8.
But my question is, what exactly is this formula doing? I can't seem to follow the logic of this array formula.
Assume a value x in A1, blanks in A2:A8.
If you use the Evaluate Formula tool, you'll see that the first step of the array formula provides an array of COUNTIFs:
=SUM(1/{1,7,7,7,7,7,7,7})
Note that there is 1 1, and 7 7s, because there is one value x, and seven blank values.
Remember that (1/n)*n = 1. So in this example,
(1/7) * 7 = 1
(1/1) * 1 = 1
Sum these results, and it's as easy as 1 + 1 = 2. :-)
Using F9 really comes in handy here. Suppose the below values are in A1:A8:
dog
cat
dog
cat
cat
dog
cat
cat
In the formula bar highlight COUNTIF(A1:A8,A1:A8) and press F9 and you will see:
{3;5;3;5;5;3;5;5}
Because there are 3 dogs and 5 cats in the list, these are the numbers that are returned by the countif formula for each appropriate type.
Now undo with CTRL+ Z or press ESC to start over. This time highlight 1/COUNTIF(A1:A8,A1:A8) and you will see:
{0.333333333333333;0.2;0.333333333333333;0.2;0.2;0.333333333333333;0.2;0.2}
Because there are 3 dogs in the list, 1/3 produces .3333333. Now .3333333 appears in the list in the same position that dog appears in the list. Add up all the .3333333 and you get 1.
Do the same for cats. 5 Cats. 1/5 produces .2, and so on.
When in doubt how a formula works, highlight portions of the formula and press F9 and you can see what it's calculating.

Reverse order of number pairs and then subtract them

I have this text in an Excel cell in column A: 2 / 12 and want to make this subtraction in another cell in column B: =12-2.
For example, values in column A are:
2 /12
3 / 10
0 / l8
0 / 0
and I want to do this subtraction in column B:
= 12-2
= 10-3
= 18-0
= 0-0
I want to appear only the results ex. 10, 7, 18, 0
How can I do this for multiple cells?
Please try:
=RIGHT(A1,FIND("/",A1))-LEFT(A1,2)
copied down to suit.
Excel has built in Text to columns feature that would probably be useful in this case.
Under data
click Text to columns
selected Delimited
Click Next
Under Delimiters in "Other" enter "/" (without parenthesis) click finish.
That should give you 2 separate columns with your values you should then be able to easily subtract them in an adjacent cell.
This is a little weird for an excel file. I am going to make an assumption that your data in column A is formatted as "Text" because otherwise it would be calculating the value. I also assumed that there is a space between the numbers and the /. So with those assumptions in mind you could have this function in column B to get your result.
This example is for Row 1 of course but you simply copy down for the other rows accordingly
=(RIGHT(A1,LEN(A1)-FIND("/",A1)))-(LEFT(A1,FIND("/",A1)-1))

Resources