Excel = operator isn't working as expected with multiple tabs - excel

I have an Excel-file with 2 tabs:
Tab1
ActorID | ActorName
--------------------
4321 | ActorName1
4322 | ActorName2
4323 | ActorName3
4324 | ActorName4
In the second tab I want to put in the name of the actor and see if it's in the array
So I used this formula: =(Tab1!A1:A10="ActorName1"), but I get FALSE. When I use the same formula in the first tab (=(A1:A10="ActorName1")) I get TRUE.
I don't understand why I get FALSE if the formula is used in another tab :/

The formula works on the tab only if the name you are searching is the first. You are trying to compare an array to a single item, Excel will only look at the first.
To search a range of names use MATCH(). To return TRUE/FALSE wrap it in ISNUMBER(), as MATCH will return a number if found or an error if not found.
=ISNUMBER(MATCH("ActorName1",Tab1!A1:A10,0))

Related

Alternate row colour by data in fields in a spreadsheet

Good Afternoon all,
I've had a search but can't find the answer - please direct me if there is one!
I'm looking to make my spreadsheet have better readability to the user. It requires a lot of manual work outside of the sheet, so the less time strain the spreadsheet is, the better.
I know to to use =mod() in Conditional Formatting but this isn't what I'm looking for
I also know about opening the filter drop down, and clicking one cell, pressing down twice and pressing space bar (rinse and repeat) - but I'm not going to do this over 1000 rows...
Is there a way to alternate the colours from a filtered name in excel?
For example:
+---------------+---------------+--------------+
| Site Code | Site Name | Changed Date |
+---------------+---------------+--------------+
| 000020 | Bobs site | 28/11/18 | <-- colour 1
| 000020 | Bobs site | 26/11/18 | <-- colour 1
| 059201 | Julian's | date | <-- colour 2
| 059201 | Julian's | date | <-- colour 2
| 002237 | etc. 1 | date | <-- colour 1
| 523878 | etc. 2 | date | <-- colour 2
| 523878 | etc. 3 | date | <-- colour 2
+---------------+---------------+--------------+
So rather than by line number, it would be by the name "bobs site" would be one colour, the next in the list would be another colour etc
I would love for this to apply to site code and site name, so when filtering by either, the rows are highlighted correctly.
I can't do this in the =mod() kind of way, as some sites have just one entry, most have 2 and a few can have up to 10
EDIT: Proof of the answer working for future references
Doable with a helper column and Conditional Formatting with COUNTIF and MOD.
In the helper column:
=OR(A2<>A1,B2<>B1)
which returns TRUE or FALSE if the site code or site name has changed (or not) compared to the previous row.
Then 2 conditional formatting rules:
=MOD(COUNTIF($D$2:$D2,TRUE),2)=0
=MOD(COUNTIF($D$2:$D2,TRUE),2)=1
The mixed reference ($D$2:$D2) in the COUNTIF will allow for each separate section to be coloured alternately as the instances of TRUE are successively added up.
One solution; get all uniq values in a seperate column, copy column you want to refer to, paste to new column, remove duplicates.
Then select area with data and start refering those values you want to have that color i conditional formatting.
Edit
With more options use "AND" or "OR"

Search for a substring in cell and return value of matrix

the following excel tables are given:
Sheet01
String: A
Output: B
+---------------------+--------------+
| String | Output |
+---------------------+--------------+
| ABC Test01 | It is Test01 |
| DEF Test01 | It is Test01 |
| Test01 GHI | It is Test01 |
| Hellow Test02 World | Wow Test02 |
| Test02 Sum Sing | Wow Test02 |
+---------------------+--------------+
Sheet02
Search Criteria: A
OutputThis: B
+-----------------+--------------+
| Search Criteria | OutputThis |
+-----------------+--------------+
| Test01 | It is Test01 |
| Test02 | Wow Test02 |
+-----------------+--------------+
So basically I want to find out if Search Criteria in Sheet02 can be found in String in Sheet01. If so, display in Output (Sheet01) value of OutputThis (Sheet02).
Following works for exact match:
=INDEX(Sheet02!B:B,MATCH(A2,Sheet02!A:A,0))
Now I simply tried to put in the like operator which doesn't make any sense. Because excel can't now what part of String is to be found in Search Criteria.
What I'm looking for is something
=New_Function(SearchCriteriaMatrix, SearchCell, OutputMatrix)
EDIT:
I just used the following code and it somehow works:
=INDEX(Sheet02!B:B,Match(A2,Sheet02!A:A,-1))
The key is "-1". It changes the criteria from an exact match to a broad match. At least that's what I want it to do, but it doesn't workout well. Perhaps someone can use this and help out.
SEARCH or FIND can find a substring within a string. So something like:
=LOOKUP(2,1/SEARCH(srchCritTbl[Search Criteria],A2),srchCritTbl[OutputThis])
will work.
I made your sheet2 table into a "real" table and I'm using structured references, but it'll work with discrete references also, but the references should encompass only the active part of the data table, and not the entire column.
Here is a screen shot showing the results:
If you were to use direct references to the table on Sheet02, it would look like:
=LOOKUP(2,1/SEARCH(Sheet02!$A$2:$A$3,
Sheet01!$A2),Sheet02!$B$2:$B$3)
The way this works:
SEARCH returns an array of either a number, or an error, depending on whether or not if finds the contents of table2 within the referenced cell in table 1.
1/Search(... will then return either an error, or some number which has to be no greater than 1.
Using 2 as the lookup criteria in LOOKUP guarantees that it will be greater than any value returned in the lookup_vector.
If the LOOKUP function can't find the lookup_value, the function matches the largest value in lookup_vector that is less than or equal to lookup_value. EDIT: As pointed out by #Gregory, this applies if lookup_vector is sorted ascending. When it is not, then the last entry that is less than or equal to lookup_value gets matched.
since result_vector references the OutputThis column, the matching entry in that column would be returned.
One could also guarantee, in this situation, that lookup_value would be greater than any value in lookup_vector by using a very large number, and eliminating the 1/... portion:
=LOOKUP(9.9E+307,SEARCH(srchCritTbl[Search Criteria],Sheet01!$A2),srchCritTbl[OutputThis])
I used the other form out of habit as it is more generally useful.
Here's a single cell array formula:
In cell Sheet01!B2 type:
=INDEX(Sheet02!B:B,MATCH(1,IF(ISERROR(SEARCH(Sheet02!A:A,A2)),0,1),0))
Press ctrl+shift+enter to complete the formula as single cell array formula
Copy this cell down to the remaining range Sheet01!B3:B6
Note: It gives the output for the first Sheet02 Search Criteria that matches, and not the first one found in the string. So the string Test02 and Test01 would output It is Test01 because Test01 is listed before Test02 on Sheet02.

Excel - count text occurrences if string is present in adjacent column

I'm trying to count values in Column A if Column B matches a certain string of text.
assets status
-----------------------------
1 | itemThing | yes
2 | |
3 | itemThing |
4 | |
5 | itemThing | yes
This above example would ideally return 2.
I want to count how many times "item" shows up in column A ONLY if column B says "yes"
I've tried something with =SUMPRODUCT but it doesn't seem to work correctly. It is currently returning 4 when there are 5 matching criteria.
I have =SUMPRODUCT((assets=A1)*(status=B1)) where assets and status are custom names for the column ranges created with Name Manager.
Edit: noticed that is has to be an exact string match for it to count correctly. How do I do partial string matches? e.g. search terms? e.g. match =SUMPRODUCT((assets="*item*")*(status=B1))
Two ways here for your reference:
SUMPRODUCT:
=SUMPRODUCT((ISNUMBER(SEARCH("*itemThing*",assets)))*(status="yes"))
COUNTIFS:
=COUNTIFS(status,"yes",assets,"*itemThing*")
For partial match, use wild card * such as "*itemThing*" and that should do the trick for you.

EXCEL 2010: COUNTIF using SUB-TOTAL (from filter) with multi criteria

Program: Excel 2010
I have a large selection of data which I filter for various reasons, I have been able to use the following to count my sales when filtered, however I want to be able add a 2nd criteria to the mix.
New: count by value B11 and C12
(B11) = Store Name
(C12) = Product Name
=SUMPRODUCT(--($C$38:$C$1000=(B11)),SUBTOTAL(3,OFFSET($C$38,ROW($C$38:$C$1000)-ROW($C$38),0)))
I have tried variations of the following however I keep getting errors:
=SUMPRODUCT(--($C$38:$C$1000=(B11),SUBTOTAL(3,OFFSET($C$38,ROW($C$38:$C$1000)-ROW($C$38),0)),(--($C$38:$C$1000=(C12),SUBTOTAL(3,OFFSET($C$38,ROW($C$38:$C$1000)-ROW($C$38),0)))
|Prod |Store
---------------
|ABC |CDA
|DEF |XYZ
|GHI |TUV
|ABC |XYZ
Prod = ABC; Store = CDA; Result = 1 (not 2)
Please help :-)
I'm not very familiar with SUBTOTAL, but this seems to work fine:
=SUMPRODUCT(--($C$38:$C$1000=(B11)),--($B$38:$B$1000=(C12)),SUBTOTAL(3,OFFSET($C$38,ROW($C$38:$C$1000)-ROW($C$38),0)))
I just added --($B$38:$B$50=(C12)) neat the beginning between the two expressions in the SUMPRODUCT
Another option to simplify formulas is to introduce a helper column which indicates whether the row is visible or not, e.g. in Z38 copied down
=SUBTOTAL(3,B38)
Now for your count with 2 criteria you can use COUNTIFS like this
=COUNTIFS(C:C,B11,B:B,C12,Z:Z,1)

Match text from column within a certain cell - Excel

I have a column of few thousand filenames that are not uniform. For instance:
| Column A | Column B |
===============================
| junk_City1_abunc | City1 |
-------------------------------
| nunk_City1_blahb | City1 |
-------------------------------
| small=City2_jdjf | City2 |
-------------------------------
| mozrmcity3_somet | City3 |
I would like to identify the city within the text in column A and return it in Column B.
I've come up with a complex formula that does the trick, but it is difficult to adjust if more cities are added within the filenames in new entries within column A.
Here is an example:
=IF(ISNA(MATCH("*"&$W$3&"*",I248,0)),IF(ISNA(MATCH("*"&$W$4&"*",I248,0)),IF(ISNA(MATCH("*"&$W$5&"*",I248,0)),IF(ISNA(MATCH("*"&$W$6&"*",I248,0)),IF(ISNA(MATCH("*"&$W$7&"*",I248,0)),IF(ISNA(MATCH("*"&$W$8&"*",I248,0)),"Austin","Orlando"),"Las Vegas"),"Chicago"),"Boston"),"Las Angeles"),"National")
It seems like there should be an easier way to do it, but I just can't figure it out.
(To make matters worse, not only am I identifying a city within the filename, I'm looking for other attributes to populate other columns)
Can anyone help?
Use the formula =IFERROR(LOOKUP(1E+100,SEARCH($E$2:$E$11,A2),$E$2:$E$11),A2)
This does *****NOT***** have to be array entered.
Where $E$2:$E$11 is the list of names you want returned and A2 is the cell to test
If no matches are found instead of errors you will just use the full name in column b.
If you want errors or expect to NEVER have then you can just use:
=LOOKUP(1E+100,SEARCH($E$2:$E$11,A2),$E$2:$E$11)
Here's a round about way that works, not all my own work but a mish mash of bits from other sources:
Assuming the sheet is setup as follows:
The formula to use is below, this must be entered using Ctrl+Shift+Enter
=INDEX($C$2:$C$8,MAX(IF(ISERROR(SEARCH($C$2:$C$8,A2)),-1,1)*(ROW($C$2:$C$8)-ROW($C$2)+1)))
Annotated version:
=INDEX([List of search terms],MAX(IF(ISERROR(SEARCH([List of search terms],[Cell to search])),-1,1)*(ROW([List of search terms])-ROW([Cell containing first search term])+1)))

Resources