How to declare a two-dimensional array by one cell formula? - excel

In Excel it is pretty simple, for example
={1,2,3,4;5,6,7,8} gives us 2 rows in 4 columns.
But when I try similar in Google Spreadsheet, it fails.
EDIT: See comments below where the language version issue was revealed.

Nearly the same syntax, but different entry methods:
Excel
Hi-light a block of cells and array enter:
={1,2,3,4,5,6,7,8}
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.
Google Sheets
Select a single cell and enter:
={1,2,3,4,5,6,7,8}
and the extension to the other cells occurs automatically:
Same is true for 2-D arrays:
If you are using Google Sheets, remember to leave enough empty cells to the right and below to hold the result.

Related

Excel formula to count multiple possible combinations in single cell

Newbie-ish with Excel here. I'm trying to keep things simple for long term ease of use since most at my job don't know much of anything with Excel or anything with VBA.
I'm looking to have a formula count cells containing up to 4 different codes (TRM2-TRM5) out of 32 possible codes. However, the cell these combinations are entered in is not required to be in any specific order.
Such as:
B1 (TRM2, R2, TRM3)
B2 (TRM2, PN1, DC5, TRM4)
B3 (PN1, IPA5c, HW2, TRM5)
B4 (PN1, HW2, R2)
The desired result of the formula is a count of 3
I don't need to count the individual number of times the TRM codes appear. Just the number of cells they appear in a range (such as B1:B99).
I've tried COUNTIFS but quickly discovered I'd have to have a COUNTIFS for each possible combination of the 4 codes.
So far the simplest way is to use multiple instances of conditional formatting that highlights the cells that contain one of the four codes and do a visual count. All the examples I've read don't have multiple values in one cell so I'm not sure how to tackle it.
For those that are curious, the purpose is error reporting for issues missed in an audit.
Thanks for the help!
Given your example, you can do this with a helper column.
Either hard code an array constant with the codes to find, or enter them in separate cells someplace. I did the latter and named that range theCodes.
Use this array formula in the helper column:
C1: =MIN(FIND(theCodes,B1&CONCAT(theCodes)))<LEN(B1)
and fill down as far as needed
This will return TRUE or FALSE depending on whether any of the codes are present in the cell.
Then, a simple COUNTIF will count all the TRUE's
D1: =COUNTIF($C:$C,TRUE)
NOTE: To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.

SUM of multiple columns text in Excel

Is the first time writing a command in excel so I have no particular idea what I'm doing.
As you can see from the image I'm trying to get in the "All Stores" column all the Stores that have the "X" in them.
At the moment the command that I'm using is displaying the output of the first cell where it finds an "X".
I have looked at some examples that I found on this topic, but I didn't find something concrete. I've tried to do it with "SUMIF" and also I've tried to use "&" in from and after "B2", "C2", "D2", but all I got was an error.
Everything that I found on this topic was how to combine numbers.
In this particular example the expected result would be "Store1, Store3".
Thank you for your support!
Yyou could use the following:
=TEXTJOIN(", ",TRUE,IF(B2="x",B$1,""),IF(C2="x",C$1,""),IF(D2="x",D$1,""))
And populate down for other products
Though it could get unwieldy if you have a lot of stores. I'm pretty sure someone else will come up with a more clever answer, but I can't think of anything else at the moment.
In E2 enter the array formula:
=CHOOSE(COUNTA(B2:D2)+1,"",INDEX(B$1:D$1,MATCH("x",B2:D2,0)),TEXTJOIN(", ",TRUE,IF(B2:D2="x",B$1:D$1,"")),"All stores")
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.
The logic is:
First of all, I image you have over several columns that you want to consider. SO you can get this date in a new worksheet by replacing "x" or a mark of choice using below formula:
=IF(A2<>"", A$1, "") just autofill to get all the values in the new worksheet.
Now focussing on the new worksheet. e.g.
Apply below formula to get the required result
=IF(COUNTA(H2:J2)-COUNTBLANK(H2:J2)=COLUMNS(H2:J2),"All Stories",TEXTJOIN(",",TRUE,H2:J2))
You can try this array formula:
=IFERROR(TEXTJOIN(",",TRUE,INDEX($A$1:$F$1,1,AGGREGATE(15,6,1/(B2:F2="X")*COLUMN(B2:F2),N(IF(1,ROW(INDIRECT("1:"&COUNTA(B2:F2)))))))),"")
To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.

Trying to display the literal value of a concatenated cell in another cell

I'm having trouble phrasing my question, so here's a screenshot. Basically I want G2 to be a field I can copy and paste into a field on a website for billing purposes. The TEXTJOIN function is the closest I've gotten to making this work but it still isn't right. I'm having the following problems:
The price of each fruit loses its ending 0's during concatenation
I intend to keep adding more fruits, but =TEXTJOIN(E:E) includes E1 which is obviously the heading
The resulting string in G2 isn't copy-and-paste-able without first copying and selecting Paste Value within Excel
Screenshot for reference:
I might not be able to avoid the last problem without VBA but I'd like to at least navigate around the first 2 issues. I suppose creating a button that would output G2's value to a Notepad document would work as well, or something along those lines.
In E2 put:
=A2&"("&TEXT(D2,"$#,##0.00")&")"
to do the concatenation.
Then just specify the start in E2:
=TEXTJOIN(", ",TRUE,E2:E1040000)
Also you can skip the helper columns with the following array version of TEXTJOIN:
=TEXTJOIN(", ",TRUE,$A$2:INDEX(A:A,MATCH("zzz",A:A))&"("&TEXT($D$2:INDEX(D:D,MATCH("zzz",A:A)),"$#,##0.00")&")")
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
When you copy a cell to the clipboard and paste it anywhere but Excel it should only paste the text, but that may depend on the website also.

Excel How to find more values that contain values in the cell next to them?

I want to use the Index formula to list data in my excel sheet.
I want to list the data of the column A that contains "finished" in the corresponding cells in column E.
Currently I'm using the following formula:
=INDEX(IMs!A:A;MATCH("finished";IMs!E:E;0))
The problem is, only the first value appears. I want to list ALL of them.
Is it possible with the vlookup formula?
Thank you very much in advance.
Kind regards,
Vanessa
First enter this formula in B1:
=COUNTIF(IMs!$E:$E,"Finished")
Then enter this array formula** in your first cell of choice:
=IF(ROWS($1:1)>$B$1,"",INDEX(IMs!$A$1:$A$1000,SMALL(IF(IMs!$E$1:$E$1000="finished",ROW(IMs!$E$1:$E$1000)-MIN(ROW(IMs!$E$1:$E$1000))+1),ROWS($1:1))))
Copy this formula down (though not the one in C1) until you start to get blanks for the results.
If the upper row reference that I chose (1000) is not sufficiently high, then change it as required. Note, however, that since this is an array formula, it is not recommended that you make this upper bound too high (and certainly don't reference entire columns!), since this will have a significantly detrimental effect on spreadsheet performance.
From your post, it also appears that you are using a version of Excel in which the argument separator in formulas is not the comma but the semi-colon. If this is indeed the case then you will need to make the necessary amendments to the formulas I provided.
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).

EXCEL 2010 - Return Highest Value that is NOT a complete number

I'm using excel 2010.
I need a formula that will return the highest value of a mixed variable.
Look up VFL will return VFL00151
A1 VFL00001
A2 VWS00004
A3 VSC00056
A4 VFL00151
A5 VCC10025
A6 VGH00122
I'm avoiding using macros.
Thanks
With Col_A referring to your range in column A, and the lookup value (VFL) in C1, the following array formula (entered by holding down ctrl-shift while hitting enter, the following formula will perform as you request:
=IF(MAX(N(ISNUMBER(SEARCH(C1,Col_A))))=0,"",INDEX(Col_A,MATCH(MAX(IF(ISNUMBER(SEARCH(C1,Col_A)),--MID(Col_A,4,99),0)),IF(ISNUMBER(SEARCH(C1,Col_A)),--MID(Col_A,4,99),0),0)))
Of course, this assumes all of your entries start with three letters, and then are followed by digits.
Also, using the same set-up and assumptions as Ron Rosenfeld, but also assuming you're using Excel 2007 or later, array formula**:
=IF(COUNTIF(Col_A,C1&"*")=0,"",INDEX(Col_A,MATCH(1,(LEFT(Col_A,3)=C1)*(0+MID(Col_A,4,99)=MAX(IFERROR(0+SUBSTITUTE(Col_A,C1,""),0))),0)))
Note also that this solution is case-sensitive whereas Ron Rosenfeld's is 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).
=MAX(--MID(A1:A6,4,LEN(A1:A6)-3))
ctrl+shitf+enter when you've entered the formula, to create an array formula. This assumes that all of your numbers have the same form, of 3 letters, then your number.
The mid formula takes the numeric part, based on the pattern you've outlined above. If the pattern is not consistent, you've got less hope with a formula. Doing this as an array, does all of the cells in the range in one step, and returns an array of numbers. This can then be 'maxed'
Update. To take this a step further, and do a lookup on the same principle (without error handling):
=INDEX(A1:A6,MATCH(MAX(--MID(A1:A6,4,LEN(A1:A6)-3)),--MID(A1:A6,4,LEN(A1:A6)-3),0))

Resources