Search text in different cells and add all results in a cell using Excel - excel

Let's say I have this list:
Colorado US
Texas US
London UK
Berlin GE
Munich GE
I would like to obtain as result all the cities that end with "US" in a cell, just like this
Colorado US Texas US
I have applied the formula:
=IF(ISNUMBER(SEARCH(find_text;within_text));"Cell_of_CityName";"")
This works perfect if I do it cell by cell.
Is there a way to apply this formula to the whole column so that I dont have to do it always cell by cell?
Thank you in advance!

in B1:
=TEXTJOIN(" ",TRUE,IF(RIGHT(A1:A5,2)="US",A1:A5,""))

Related

If a cell's value is found on another column, how to return the cell's value from another column which is on same row with the synced cell?

My Excel table is looking like this.
A column is the one that I want to fill in with correct data.
B column is where the lookup values are.
C column is the one where I want to extract data from.
D column is where data from B column will be searched.
For example, if data from B2 is found on D7 cell, I want to have in A2 the value from C7.
My Countries///My Codes////All Countries//////All Codes
AD Afghanistan AF
AU Albania AL
Algeria DZ
American Samoa AS
Andorra AD
Angola AO
Anguilla AI
Antarctica AQ
Antigua and Barbuda AG
Argentina AR
Armenia AM
Aruba AW
Australia AU
Austria AT
Azerbaijan AZ
It would be much appreciated your help because I would like to learn as much as I can about excel formulas.
Kind Regards,
Ioan
In A1 enter:
=INDEX(C$1:C$15,MATCH(B1,D$1:D$15,0))
and copy down:
Note:
MATCH() finds the row.INDEX() grabs the value.
Chris is right, looks like you need a vlookup, example
B1 would be
=Vlookup(A1,c1:d200,2,0)
B2 would be
=Vlookup(A2,c1:d200,2,0)
And so on
It works like this
Vlookup (value to lookup, range the lookup and return values are in, column number from range you want to return, exact match only (0 or false))
Though Chris's link is more detailed

Sum Multiple values in different Rows using Vlookup Function

A B
France 152
Italy 255
France 221
Spain 215
USA 222
Spain 155
I desire to add each value occurring in front of repeating countries using Vlookup function
Solution:
A B
France 373
Spain 370
If you use a SUMIF then you can total the columns
If the data starts in cell A1 then in cell C2 type
=SUMIF(A:A,A3,B:B)
then drag the formula down. this will give totals for each country
Or if you just want to show the first instance (where it says France for example) then use
=IF(COUNTIF(A$1:A2,A2)=1,SUMIF(A:A,A2,B:B),"")
You won't be able to do it with a vlookup.
You could use a pivot table which might be easier and that is useful for this exact type of question.
To get the list of repeating countries enter the following formula in Cell D2
=IFERROR(INDEX($A$2:$A$7,MATCH(1,INDEX((COUNTIF($D$1:D1,$A$2:$A$7)=0)*(COUNTIF($A$2:$A$7,$A$2:$A$7)>1),0,0),0)),"")
Then to get sum of corresponding country, in Cell E2 enter
=SUMIF($A$2:$A$7,D2,$B$2:$B$7)
Drag/Copy formulas as required. See image for reference.

Excel Index Partial match

I have Sheet1 with column A listing every single country in alphabetical order..
A
1 Afghanistan<
2 Albania
3 Algeria
4 American Samoa
5 Andorra
----------
228 United Kingdom
229 United States
etc
I have Sheet2 column A with empty cells with adjacent cells in column B listing address details
A B
1 empty cell Unit 3, Road;London, United Kingdom
2 empty cell Building 1, Road, TX, United States
3 empty cell 8th floor, Business Park, India 1234
etc
What I would like to know is how can I obtain the country within the address details in sheet2 column B and place them in Sheet2 column A, based on a match on the list of countries in Sheet1 column A.
Part of the problem is there is no coherent method as to how to country is placed within the address; could be at the end or in the middle of the address.
I have tried various index match formulas with no luck
any help would be appreciated.
I tried it with the reference table being in A1:B7, and lookups being A10:B10 onwards down. The formula is for these cells. You can adjust it for Sheet1/2!.
Assuming your data is in B10 onwards, and your reference data was in B1:B7, you can write this formula in A10 =INDEX($B$1:$B$7,MAX(IF(ISERROR(FIND($B$1:$B$7,B10)),-1,1)*(ROW($B$1:$B$7)-ROW($B$1)+1))). This is an array formula, so please hit Ctrl+Shift+Enter for excel to read it as an array formula.
(In the screenshot, I have pasted the table in A10:B12 as values only in D10:E12)
Text to Columns with a comma delimiter

Formula to Get data for a specific date

Date Time Country Desc
16/04/14 8.30 am India abcd
16/04/14 9.30 am India pqrs
17/04/14 9.30 am India xyz
17/04/14 10.30 am India abcd
I wish to get all the data of 16/04/14 in another sheet using formula. Vlookup takes only the first row data as reference is 16/04/14. Is there any other way to get data.
Try this then:
Assuming you have this data in Sheet1:
And you want to get all matches of dates in Sheet2 like this:
What you need to do is use this formula:
=IFERROR(INDEX(Sheet1!A$1:A$5,SMALL((IF(Sheet1!$A$1:$A$5=$E$1,ROW(Sheet1!A$1:A$5))),ROW($A1)),1),"")
Above is an Array Formula entered by pressing Ctrl+Shift+Enter.
Enter it in A2 then copy on the remaining cells.
For our example, I copied it until Row 10 (A2:D10).
Then you just need to type in the value you want displayed in E1 as shown in the picture.
Then all the columns will populate with the data that you need.
Hope this helps.
Important: The ranges in the formula needs to be adjusted to suit your needs.

Count the number of companies per country in Excel

I have the following 2 excel sheets in the same workbook:
companies:
A B
1 COMPANY COUNTRY
2 Apple USA
3 Microsoft USA
4 Samsung Taiwan
5 Philips Netherlands
6 Tulip Netherlands
countries:
A B
1 COUNTRY NUM_COMP
2 USA 2*
3 Taiwan 1*
4 Netherlands 2*
In sheet countries column B I need the number of companies per country. I have now counted them by hand, but I need a formula for cells B2 to B4 to do this automagically, since the actual sheet is much, much longer than this example.
Can anyone help me? Your help is greatly appreciated.
Function 'Countif' should be helpfull :)
=COUNTIF(B:B;B2)
cheers
Sky
For the number of different companies per country try this formula in B2
=SUM(IF(FREQUENCY(IF(companies!B$2:B$2265=A2,MATCH(companies!A$2:A$2265,companies!A$2:A$2265,0)),ROW(companies!A$2:A$2265)-ROW(companies!A$2)+1),1))
That's an "array formula" which needs to be confirmed with CTRL+SHIFT+ENTER so that curly braces like { and } appear around the formula in the formula bar.
Now copy formula down column

Resources