How to convert Vlookup to Index/match? - excel

Puzzle 1 | Attempt 1 | 0
| |7.1
Suppose I have 3 columns like the above, the blank spaces have nothing in the cell. I want to get the value of 7.1
I've tried
VLOOKUP("Puzzle 1",A:D,1)
To get the value "puzzle 1" and then trying to enclose that in an OFFSET(VLOOKUPVLAUE, 1,2,11) which does not work.

=INDEX(C:C,MATCH("Puzzle 1",A:A,0)+1)
would work for that.

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"

sum values of cells in google sheets if the result of their sum with adjacent cell meets a condition

Suppose I have the following data in a spreadsheet, where the first row contains the column headings and the first column contains the row index (for reference):
||A | B | C |
==||================
0 ||2 | 3 | Y |
--||----------------
1 ||2 | 4 | Y |
--||----------------
2 ||3 | 5 | N |
--||----------------
3 ||8 | 3 | Y |
--||----------------
How can I get the sum of all the values in column B for which b - a >= 1 && c == "Y", in Google Sheets and Excel?
So essentially, the sum should factor in only rows 0 and 1 in which case the result should be 7.
I know this sounds like a very specific question but I did not know how else to describe it other than by example. The answer should be applicable in other similar scenarios.
Thanks for the help.
[Edit] In response to people voting down due to lack of research, well, I've tried to use the sumif() function but I got stuck immediately on the condition part as I am not sure how to compare the current item in the aggregation with another cell. I also tried to use the sumifs() function which allows for multiple criteria, but also to no avail. As for my research, I searched on Google but could not find anything, possibly due to my inability to express the requirement in a manner suitable for a google query. Therefore, I have presented the above as a way of explaining my requirement by example.
I hope this helps.
I appreciate that this may not be possible to do with the simple built in formulas. If this is the case, please mention it as that would also be useful to know.
Thank you.
Excel: =SUMPRODUCT(((B:B-A:A)>=1)*(C:C="Y")*(B:B))
Untested, but let me know if it works. Next time, remember to add an example of code/formulas that you have already tried and what error you ran into.
Edit:
Tested it, here is a screenshot of it working with your example data (disregard the fact that my Excel is in spanish)
This works by intersecting both logical tests (that is, performing a logical AND): (B-A)>=1 AND C="Y". Here you can see the result of each logical test and then, finally, where it evaluates to TRUE it returns the value in column B; where it's FALSE, it returns 0. Finally, it sums the values in the result array.

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.

Return values, based on value of an intersection of a row and column

I want to return a label(s) based on an intersection of a Row and Column equal to "Yes".
| Location |
ID | Tool | Wall | Bin | Toolbox | Count
---+--------+------+-----+---------+-------
1. | Axe | YES | | | 1
2. | Hammer | | | YES | 5
3. | Pliers | | | YES | 2
4. | Nails | | YES | | 500
5. | Hoe | YES | | | 2
6. | Screws | | YES | | 200
7. | Saw | YES | | | 3
What's in Toolbox? (Results wanted)
Axe,Wall, 1
Hammer, Toolbox, 5
Pliers,Toolbox, 2
Nails,Bin, 500
Hoe, Wall, 2
Screws, Bin, 200
Saw, Wall, 3
I also want to be able add Tools and Locations?
Without using VBA, this is going to be a bit of a pain, but workable if you don't mind helper columns. I don't advise trying to do this in a single Array Formula, because text strings are hard to work with in Array formulas. That is - if you have an array of numbers, you can turn that into a single result a lot of ways (MIN, MAX, AVERAGE, SUM, etc.). However with an array of strings, it's harder to work with. Particularly, there's no easy way to concatenate an array of strings.
So instead, use a helper column. Assume column A = toolname, column B = a check for being on the wall, column C = a check for being in the bin, column D for being in the toolbox, and column E for the number available.
FORMATTING SIDE NOTE
First, I will say that I recommend you use TRUE/FALSE instead of "yes"/"no". This is because it is easier to use TRUE / FALSE within Excel formulas. For example, if you want to add A1 + A2 when A3 = "yes", you can do so like this:
=IF(A3="yes",A1+A2)
But if you want to check whether A3 = TRUE, this is simplified:
=IF(A3,A1+A2)
Here, we didn't need to hardcode "yes", because A3 itself will either be TRUE or FALSE. Also consider if you want to make a cell "yes" if A3 > 5, and otherwise be "no". You could do it like this:
=IF(A3>5,"yes","no)
Or, if you used TRUE/FALSE, you could simply use:
=A3>5
However, I'll assume that you keep the formatting you currently have (I would also recommend you just have a single cell that says either "toolbox"/"bin" etc., instead of 4 columns where 1 says "yes", but we'll also assume that this needs to be this way).
BACK TO YOUR QUESTION
Put this in column F, in F2 for the first cell:
=Concatenate(A2," ",INDEX($B$1:$D$1,MATCH("yes",B2:D2,0))," ",E2)
Concatenate combines strings of text into a new single text string. You could also use &; like: A2 & " " etc., but with this many terms, this is likely easier to read. Index looks at your header row 1, and returns the item from the first column which matches "yes" in the current row.
Then put the following in F3 and drag down:
=Concatenate(F2," ", A2," ",INDEX($B$1:$D$1,MATCH("yes",B2:D2,0))," ",E2)
This puts a space in between the line above and the current line. If instead you want to make each row appear after a line-break, use this:
=Concatenate(F2,CHAR(10), A2," ",INDEX($B$1:$D$1,MATCH("yes",B2:D2,0))," ",E2)

Excel Conditional Formatting - Containing Multiple Matches

Trying to avoid VBA and use one Conditional Formatting rule.
I want to apply a format to cells that contain one or more possible phrases.
| A |
---+--------+---
1 | foo |
2 | bar |
3 | foobar |
4 | baz |
5 | foobaz |
6 | qux |
7 | barqux |
Goal: apply conditional format to 'foo' and 'baz' (rows 1,3,4,5)
Something like the following should work, however I think the problem is in identifying the current cell to compare, in this case the A1:A7 needs to be the current cell reference:
=OR( IFERROR(FIND("foo",A1:A7),0) > 0, IFERROR(FIND("baz",A1:A7),0) > 0 )
Any ideas?
I found the answer.
Even though the conditional format was being applied to the range $A$1:$A$7, all you need to do is refer to the first cell in the function.
=OR( IFERROR(FIND("foo",A1),0) > 0, IFERROR(FIND("baz",A1),0) > 0 )
It'll automatically increment so long as you don't use the lock operator ($). - Sorry if this is common knowledge. I'm going to keep this here for educational purpose, if no one has a problem.
You're perfectly right. You have to enter the reference to the "selected" cell. E.g. if you click into cell A1 and then drag and select cells A1..A7 you will see that A1 has different background than the other cells. This is your current cell for the conditional formula. I.e.
=OR( IFERROR(FIND("foo",A1),0) > 0, IFERROR(FIND("baz",A1),0) > 0 )
would be correct in this case. For the other cells the formula will then be adjusted accordingly.

Resources