Array sum of numeric element of alphanumeric values - excel

I have a series of alphanumeric data in 'A' column:
I want the sum of the numeric values in cell "B1" for all ending with k and a sum of all ending with p in cell "C1".
I mean adding all the numeric element of the values.

Apply Text to Columns to ColumnB with fixed width and the split after the first character.
in C1 enter =A1&B1 and copy down to suit.
in D1: =SUMIF(B:B,"k",A:A)
in E1: =SUMIF(B:B,"p",A:A)
Select ColumnsC:E, copy, Paste Special…, Values over the top.
Delete ColumnsA:B.

Perhaps with an array formula**:
=SUM(IF(RIGHT(A1:A100)="k",0+SUBSTITUTE(A1:A100,"k","")))
Change the range (A1:A100) to a suitably larger one if required - though not TOO large (and certainly don't use A:A!) since, unlike e.g. SUMIF(S), array formulas calculate over all cells within the range, whether beyond your last non-empty cell or not.
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).

Related

Capture adjacent Cell with condition Ask Question

Capture adjacent Cell with condition
I have values in A column and corresponding values in B column. I need to capture based on A column value I need to capture adjacent cell value which has no zeros.
Say we have data like:
and we want to retrieve a value from column B that corresponds to alpha in column A, but which is not 0. We can use an array formula with MATCH()to achieve this:
First place:
alpha
in cell D1 and in E1 enter the array formula:
=INDEX(B:B,MATCH(1,(A:A=$D$1)*(B:B<>0),0),1)
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

excel: list all values of a column of a range based on a condition

I have a range in a Excel Sheet table that contains 2 columns like A and B.
I want to list in another column all values from column A if the corresponding value in column B is not null.
I know a way to do it, but it produces a lot of "empty raws" like in column C
=if(B<>"";A;"")
I would like to do it in a compact way, with no "empty raws" like in column D
Here is an example for data down to row #19. In C1 enter the array formula:
=IFERROR(INDEX($A$1:$A$19,SMALL(IF($B$1:$B$19<>"",ROW($B$1:$B$19)),ROW(1:1))),"")
and copy downwards. (You may need to use semi-colons in place of commas)
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

Excel Max Length of each column data

Simple one for someone hopefully. I'm trying to get the max length of each column in an excel sheet but it doesn't seem to be working now. I was using =MAX(LEN(A2:A200)) for example and because MAX is not an "official" formula but is still there you seem to have to press CTRL + ALT + SHIFT once you have finished typing it.
When I do this it puts curly brackets round the whole formula like this {=MAX(LEN(A2:A200))} but if I click into the cell they disappear. the length of the first column will appear but then if I autofill to the next column it shows same length of column data from the first column rather than calculating the next column.
Perhaps not a straight up programming question but scratching my head why this is not working now. I'm trying to show max length of each column above header column in new row.
Thanks
Andrew
In A1 enter the array formula:
=MAX(LEN(A2:A200))
then stop clicking.
Move to A1 with the ARROW keys. Touch Ctrl+c. Then paste to B2 through G2 using Ctrl+v:
This will put the array formula in the destination cells.
Use Gary's formula and instead of ENTER, do CTRL-SHIFT-ENTER
When I do this it puts curly brackets round the whole formula like this {=MAX(LEN(A2:A200))} but if I click into the cell they disappear. the length of the first column will appear but then if I autofill to the next column it shows same length of column data from the first column rather than calculating the next column.
It is right to use formulas with brackets (they are called Matrix formulas). The brackets disappears because when you edit the content of the cell you have to push Ctrl + Shift + Enter and not only Enter like normal formulas.
Let's assume all your data is in Sheet1 starting at cell A1.
Create Sheet2
Enter the =LEN(Sheet1!A1) formula in cell A1 on Sheet2
Pull Sheet2's A1 cell down/over to the right to cover the populated
range of Sheet1 (to copy the formula to every cell of the range in
scope) - this will give you the length of every cell in scope
Enter the =MAX(A1:A10) formula on Sheet2 in the first column below
the last line (A10 is assumed to be the last line of the first
column in this example - so the formula goes in A11)
Pull Sheet2's A11 cell over to the right till the last column to get
the MAX length of values for each column

I need to find an excel formula that I can use to create a unique list of Item numbers from an array

I need to find an excel formula that I can use to create a unique list of Item numbers from an array. I do not want to count them I just want to make a list of the Item Numbers. These part numbers are actually Alpha Numeric and can have repeating numbers through out the array multiple times. There is one other catch this list will have empty cells in it and could also be the first record in the array. This data is being pulled into Excel through a Jet report add-in for Excel.
Example: Starting in cell A1..A9
Item No.
<BLANK>
7810042050
783979
7810006045
7810006042
7810006032
<BLANK>
7810006022
7810006032
With values in column A, in C1 enter:
=MAX(A1:A10)
in C2 enter the array formula:
=MAX(IF(A$1:A$10<C1,A$1:A$10,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
EDIT#1:
Chris Neilsen has pointed out that the values in column A are actually Text rather than Numeric. To accommodate this, two changes must be made to the formulas:
A1 must be excluded
the alphas must be converted to numeric.
So we will replace the normal formula:
=MAX(A1:A10)
with the array formula:
=MAX(--(A2:A10))
and replace:
=MAX(IF(A$1:A$10<C1,A$1:A$10,""))
with the array formula:
=MAX(IF(--(A$2:A$10)<C1,--(A$2:A$10),""))
and then copy down.
If you have alpha characters in the part numbers you can do this in 2 steps.
Both are array formulas and you need to use Ctrl-Shift-Enter
Col B - sorted list of items in Col A
B2 =IFERROR(INDEX($A$2:$A$10,MATCH(COUNTA($A$2:A2),COUNTIF($A$2:$A$10,"<="&$A$2:$A$10),0),1),"")
Col C - eliminate the duplicates
C2 = IFERROR(INDEX($B$2:$B$10, MATCH(0, COUNTIF($C$1:C1, $B$2:$B$10), 0)),"")
Copy both formulas down.
I tried to combine the two formulas but nesting an array (results in Col B) with varying row ranges did not work out. I could not find a way but the two formulas together will work.
Enter this Formula Array in B2 and copy to B3:B10
FormulaArrays are entered pressing [Ctrl] + [Shift] + [Enter] simultaneously, you shall see { and } around the formula if entered correctly
=IFERROR(
INDEX($A$2:$A$10,
MATCH(1,1+COUNTIF($B1:$B$1,$A$2:$A$10)+(($A$2:$A$10="")*1),0)*1),"")

How to count blanks in a row, after first Non Blank cell of that Row

For instance i have a range "B3:AY3" and first non blank cell that contains value is "R3", i need to count all blank cells after cell "R3"
This formula must be array-entered:
A3: =COUNTBLANK(OFFSET(MyRange,0,MATCH(
TRUE,LEN(MyRange)>0,0)-1,1,COLUMNS(
MyRange)-MATCH(TRUE,LEN(MyRange)>0,0)+1))
where MyRange = B3:AY3
and fill down as needed
To array-enter a formula, after entering
the formula into the cell or formula bar, hold down
ctrl-shift while hitting enter. If you did this
correctly, Excel will place braces {...} around the formula.
The above formula will return an error message if there are ONLY blank cells in the range, or if there are any cells in the range which contain an error. If that is a problem, use the following array-entered formula instead:
=IFERROR(COUNTBLANK(OFFSET(MyRange,0,MATCH(
TRUE,IFERROR(LEN(MyRange)>0,TRUE),0)-1,1,COLUMNS(
MyRange)-MATCH(TRUE,IFERROR(LEN(MyRange)>0,TRUE),0)+1)),COLUMNS(MyRange))
IT will count errors as being non-blanks, and count all the cells if all are blank.
and first non blank cell that contains value is "R3"
I have taken the example for Row 1. Amend as applicable :)
Try This
=COUNTBLANK(INDIRECT(ADDRESS(1,MATCH(TRUE,LEN(A1:AY1)=0,0)) & ":AY1"))
Enter this as an Array Formula. i.e you have to press Ctrl + Shift + Enter instead of Enter
For 3rd row, the formula becomes
=COUNTBLANK(INDIRECT(ADDRESS(3,MATCH(TRUE,LEN(A3:AY3)=0,0)) & ":AY3"))
If you only need it to work for row three then use the following:
=COUNTBLANK(B3:AY3) - (MATCH(TRUE,INDEX((B3:AY3<>0),0),0)-1)
This is a regular formula and will not need to be entered as an array, also as I am not using any Volatile function (like INDIRECT and OFFSET) in should also be much better performance wise.
All I m doing is counting all blanks, then subtracting all the blanks before the first cell with a value.

Resources