Excel 2007 Report Number of Occurrences in Second Column - list

B5:B53 Is a list of values I will be pasting into regularly.
In C5:C53 I would like to count the occurrences of the item.
SO:
Apple 1
Banana 1
Orange 1
Apple 2
Plum 1
Orange 2
Apple 3
I just can't seem to get the COUNTIF (think that's what should do it) to work.
Then when I go back in and paste another list into that B column range the C column will update.

You need to make the range dynamic. The first cell in the range is fixed while the second is relative:
=COUNTIF($A$1:A1,A1)
So as it is dragged/copied down the second part of the range will change thus always looking from the cell up.

Related

Using Filter function in Google Sheets to filter cels that contain a certain value

I am trying to use the filter function or any related function in order to filter all values that contain that value, but for some reason I am not succeeding yet.
To use an example, in the list below I would like to filter all values that contain banana.
Let's assume that this is Column A row 1-6 in the Google Sheet.
Banana flavor
Mandarin
Banana
Banana boat
Banana beach
Peach
EDIT
Following both your comments:
"Is it also possible to put them vertical without blank cells?".
AND
"it only returns Banana if you enter Banana in my file, not if you enter banana. How can this be fixed?"
The fix
To have the formula omit blank cells, wrap in a query and in order to make the regex case insensitive, use (?i).
=QUERY(
INDEX(IF(REGEXMATCH(A1:A7,"(?i)Banana")=true,A1:A7,)),
" where Col1<>'' ")
You can even have the value Banana in a cell like D1
In that case one should use
=QUERY(
INDEX(IF(REGEXMATCH(A1:A7,"(?i)"&D1&"")=true,A1:A7,)),
" where Col1<>'' ")
Original answer
Please try
=INDEX(IF(REGEXMATCH(A1:A7,"Banana")=true,A1:A7,))
(Do adjust the formula according to your ranges and locale)

Highlight duplicates when part of the cell matches in Google Sheets

I have searched as much as I can, and I have found solutions for similar problems, but I haven't been able to find a solution to my exact problem.
Issue: I would like to highlight the row when one cell in column A of that row is an exact match for another cell in that column, AND part of another cell in column B of that row is a match for part of another cell in that column, in Google Sheets. I would like to use conditional formatting, and only highlight the second occurence and on.
For example, is this "sheet":
A B C
1|John Smith|john#test.com|Test Co.
2|Jane Doe |jane#x.com |X Company
3|John Smith|j.s#test.com |Test Inc.
4|John Smith|jsm#test.com |Test Incorporated
I would like row 3 and row 4 to highlight, because column A3 is a duplicate of A1, and everything in B3 after # matches everything in B1 after #, and the same is true of row 4. Also, only rows 3 and 4 should highlight; not row 1, since it is the first instance. I understand regexes, and I've found how to highlight a row if one cell in column A and one cell in column B is an exact match with other cells is their respective columns, but I haven't figured out how to combine the two where I can search for one cell that is an exact match with another cell in that column AND for one cell that is a partial match with another cell in that particular column. Here is a link to a test sheet that contains the sample info from above. https://docs.google.com/spreadsheets/d/1neZd213C1ssY7bPeBfu2xI3WPCmt-oKkfbdrXrid9I8/edit?usp=sharing
use:
=INDEX(COUNTIFS($A:$A&REGEXEXTRACT($B:$B, "#.+"), $A1&REGEXEXTRACT($B1, "#.+"),
ROW($A:$A), "<="&ROW($A1))>1)*(A:A<>"")
Try the following custom formula applied to A1:C:
=index((countif($A$1:$A1,$A1)>1)*
(countif(regexextract($B$1:$B1,"#(.*)"),
regexextract($B1,"#(.*)"))>1))

Google Sheets - Cell contains text

I have a google sheet with cells that contain different words. I want the words to equal numbers if present in a different cell. Normally I can just use =if when there is just one word but can't for this. I've tried using =regexactmatch and =search but can't get it to work.
For example the cell might contain the following text:
"Uruguay, France, Brazil, Belgium"
I want Uruguay, France, Brazil to each = 3 in another cell but Belgium to = 0 in that same cell.
I think does what you ask:
=substitute(substitute(substitute(substitute(A1,"Uruguay",3),"France",3),"Brazil",3),"Belgium",0)
but, possibly like user who VTC'd as Unclear, I doubt it is what you want.

Concatinate in OPEN OFFICE removing Leading zeroes

A B C D
2 DRUGS 000000000004 2 PARACETAMOL (ACETAMINOPHEN) TAB 500 MG
This is my entry in my open office so we have here the row 2 with columns A-D
I have create a formula =CONCATENATE("('" ;A2;"','";B2;"','";C2;"','";D2;"'),")
and this one give me this result:
('DRUGS','4','2','PARACETAMOL (ACETAMINOPHEN) TAB 500 MG'),
Basically I want a result like:
('DRUGS','000000000004','2','PARACETAMOL (ACETAMINOPHEN) TAB 500 MG'),
Column B is set to Number with Leading zeroes set to 12.
What I want is to get a result where the leading zeroes in column B is will retained.
=CONCATENATE("('" ;A2;"','";TEXT(B2;"000000000000");"','";C2;"','";D2;"'),")
Use any mask you want as the second parameter to the TEXT function
More on TEXT and other text functions: https://help.libreoffice.org/Calc/Text_Functions#TEXT
Please try:
=CONCATENATE("('";A2;"','";REPT("0";12-LEN(B2));B2;"','";C2;"','";D2;"'),")
I suspect what you have in B2 is 4 formatted with many leading 0. If so, it is possible, assuming many other entries, that some will be text and the cell content actually something like 000000000004 - for which the above formula will not work (but yours should).

Remove duplicates and Keep related data Calc (Excel)

I have a list of products in calc (excel), each with an associated IP address. Many of the names have multiple IP addresses, however they are organized one column at a time. I am trying to remove all of the multiples and pull all of the IP addresses under a single name. I have tried nslookup and index match, they do not deal well with multiple outputs though. Right now it looks like this
a| 1
a| 2
a| 3
b| 1
b| 2
b| 3
etc...
I would like it to look like this
a 1,2,3
b 1,2,3
Is there any way to do this without wasting a ton of time, I have a few ways that work but they will take me forever to setup.
I recommend setting up your formulas in multiple "helper" cells before getting to the final "result cell". This breaks down the problem into smaller steps that are more easily formulated and, if needed in the future, updated. Once the setup is complete you can hide the helper columns by right-clicking on the column letter and choosing "Hide".
The first column to set up is the list of distinct product names. For the formula below to work, the product/IP list will need to be sorted in ascending order. If the list is not already sorted, to sort it first highlight the entire list, including headers. Then choose Data→Sort; select sort by "Product", make sure the radio button "Ascending" is selected, and press OK.
For purposes of this example, I'll assume product names are in column A, starting on row 2 and IPs are in column B starting on row 2 (with row 1 being the header labels). In the column where you want to list the distinct product names (I used column D), enter in the top cell =A2. In the cell below enter
=INDEX($A$2:$A$13;MATCH(D2;$A$2:$A$13;1)+1)
The match formula has a 1 as the third variable, meaning the range is sorted ascending and MATCH will return the position of the last matching cell. We add 1 to the position of the last matching cell, and this will be the position of the first cell with a new product name. That position is fed into the INDEX function to show the next product name.
Copy and paste that cell down as far as you need to show all the product names.
Now we'll set up a series of cells to display each IP address. I used columns F to I to show up to 4 addresses:
=IF(MATCH(D2;$A$2:$A$13;0)<=MATCH($D2;$A$2:$A$13;1);INDEX($B$2:$B$13;MATCH($D2;$A$2:$A$13;0));"")
=IF(MATCH(D2;$A$2:$A$13;0)+1<=MATCH(D2;$A$2:$A$13;1);INDEX($B$2:$B$13;MATCH(D2;$A$2:$A$13;0)+1);"")
=IF(MATCH(D2;$A$2:$A$13;0)+2<=MATCH(D2;$A$2:$A$13;1);INDEX($B$2:$B$13;MATCH(D2;$A$2:$A$13;0)+2);"")
=IF(MATCH(D2;$A$2:$A$13;0)+3<=MATCH(D2;$A$2:$A$13;1);INDEX($B$2:$B$13;MATCH(D2;$A$2:$A$13;0)+3);"")
MATCH with the third variable of 1 returns the position of the last matching cell; MATCH with the third variable of 0 returns the position of the first matching cell.
The IF statement checks if the position of the first matching cell (in the first lookup column) or the cell below that (in the second lookup column) or the cell two below the first match (in the third lookup column), etc. is less than or equal to the position of the last matching cell. If yes, then it looks up the relevant IP address. If no, it displays a blank.
In the formulas above you would need to manually enter the formula in the top row of each column. If you have some products with a large number of IP addresses, you may want to set up the formula so you can copy and paste between columns as well as down the rows. This would work if you were starting in column F:
=IF(MATCH($D2;$A$2:$A$13;0)+COLUMN()-6<=MATCH($D2;$A$2:$A$13;1);INDEX($B$2:$B$13;MATCH($D2;$A$2:$A$13;0)+COLUMN()-6);"")
Once you have your top row set up as you want, copy and paste down however many rows you need.
If you want to combine all the IPs into a single cell separated by commas, you can use a formula like this:
=CONCATENATE(F2;IF(G2<>"";","&G2;"");IF(H2<>"";","&H2;"");IF(I2<>"";","&I2;""))
Each IF statement will add a comma separator followed by the cell contents if the checked cell is not empty, otherwise it returns a blank string. You will need to manually adjust to add additional IF statements for however many maximum columns you want to concatenate. Again, once you have the top row set up, copy and paste down however far you need.
Assuming you have two columns (A and B), that these are labelled and sorted as shown, then enter in C2:
=IF(A1<>A2;B2;C1&","&B2)
and in D1:
=A1<>A2
Copy both down to suit, select ColumnC and Copy, Paste Special... with each Selection ticked other than Paste all and Formulas, click OK.
Select ColumnsA:D, Data > Filter > AutoFilter, click Yes and select 1 for ColumnD and all visible range.
Copy and paste into a new sheet, move B1 to C1 and delete Columns B and D.