Combining IF Statement along with CONCATENATE if it exists - excel

Trying to combine and IF + Concatenate together. I'm running a report right now for my company where we grab samples from different water locations, but due to COVID-19 we aren't allowed in some specific locations and therefore have to get a water sample from a nearby hydrant.
I have all the locations and hydrants in one spreadsheet as data, and in my main tab I have an empty cell where someone may put (YES/NO) and if they put YES then another cell will fill with the hydrant name along with the location.
My issue is I have to have both this data combined in one static cell if "YES" is put, for example...
Location: LOC-3 John Street
Hydrant used?: YES
Hydrant (auto filled): LOC-3 HYDRANT 3333
Full location name (if YES): LOC-3 John Street LOC-3 Hydrant 3333
Full location name (if NO): LOC-3 John Street
This is the code below that I'm using in order to return the location name, can't figure out where or how to throw concatenate in there without getting an error back. Thank you in advance for your help.
=IF(OR((AND((A6<>""),(D6<>""))),(AND((B6<>""),(D6<>"")))),IF(A6="",B6,A6),"")

(Not a complete answer, but too large for a comment)
Your first part of your logical expression is quite large, let's have a look:
[(a6<>"") AND (d6<>"")] OR [(b6<>"") AND (d6<>"")]
=[(a6<>"") OR (b6<>"")] AND (d6<>"")
=[(a6&b6) <> ""] AND (d6<>"")
Where a6&b6 has the Excel meaning (concatenation of a6 and b6).
This is already a significant simplification of your formula. You might try to simplify even further and go on from there.

Related

Excel; How to find character and give matching description

I have a table with clients and specific markers for each shop:
Client
Markers
Location
Jane
B,D,K,M,f,n,,+
Max
B,D,J,K,M,f,i,n,+
Ted
D,i,a,1,J,Y,K,M
Maria
C,D,J,K,M,n
Alex
A,D,K,M,f,i,n
Tom
A,D,K,M,f,m,o,y,+
Richard
R,D,J,K,M,f,i,n
X
A,D,K,M,f,n
Red
A,D,K,M,f,i,n,+
John
C,D,F,K,M,f,i,n,4
Lex
T,D,a,1,4,T,K,M
Ted
D,a,1,T,K,M
Jane
D,a,1,T,K,M
Another table contains the Locations:
marker
desc
A
New York
B
Amsterdam
C
London
H
Tokyo
Q
Paris
R
Vancouver
T
Sydney
Y
Auckland
Now I want to fill first table with locations but going wrong when first marker isn't the location marker. I used: =VLOOKUP([#Markers],TableLocations[marker],1,TRUE), I've tried the MATCH function but this gives the wrong number again.
So only works fine when first character in the marker column matches the marker in the location table.
To find only for first marker location from comma separated values from each cell in first column, you can use-
=XLOOKUP(TEXTBEFORE(B2,","),$G$2:$G$9,$H$2:$H$9)
For multiple location try-
=TEXTJOIN(", ",TRUE,FILTER($H$2:$H$9,ISNUMBER(XMATCH($G$2:$G$9,TOCOL(TEXTSPLIT(B2,",")),0))))
For dynamic spill array at one go, try-
=BYROW(B2:B14,LAMBDA(x,TEXTJOIN(", ",TRUE,FILTER($H$2:$H$9,ISNUMBER(XMATCH($G$2:$G$9,TOCOL(TEXTSPLIT(x,",")),0))))))
Try this, using tables and structured references (which you can change to normal addressing if you preferred, but the former are more dynamic).
In your comments you indicated there would be only one location per client; if you need more than one, please clarify
Edit: corrected missing structured reference
=INDEX(Location[desc],AGGREGATE(14,6,BYCOL(EXACT(TEXTSPLIT([#Markers],","),Location[marker]),LAMBDA(arr,XMATCH(TRUE,arr))),1))
Note: One can get case-sensitive matches using either EXACT or FIND functions. But, because of the null string in the list in your first row (note the doubled-comma in the Markers), FIND will always return a match for that, potentially causing an incorrect result

concatenate an address based on multiple cells, some of which may be blank

This is an address list that has a field for po box (number only)[A1], street number[A2], street name[A3].
Objectives
use PO Box over street address where there are both OR no street given
then concatenate "P.O. Box "& A1; to get "P.O. Box 1234" as the second line under the name
OR, if po is blank, concatentate street number and name: A2&" "&A3; to get "1234 Smith Street"
THEN join the results to produce a mailing label with the city,state,and zip cells.
Everything I come up with give Excel (and me) a bellyache. It hates empty cells, circular refs, etc.
1124 Kenilworth Ave.
i did Col I by hand. {=If(F2>"","P.O. Box "&F2,G2&" "&H2)} is a no go:excel does not like the empty G and H cells. I don't seem to grasp the various of blank, isblank,isnotempty, etc. for they all fail. This seems pretty basic conditional choice. test for presence in one col and act accordingly: if the first test is met, why balk at the second.
Any help appreciated.
The initial question is which kind of address to create, street or postbox.
=IF(OR(COUNTA($F3)=1,COUNTA($F3:$H3)=0),"P.O.Box "&IF(COUNTA($F3),$F3,$A$1), "Street address")
The above formula determines that (a) if a Box number is given OR (b) no addressing information is available at all a Box address must be returned. In the latter case, if there is no box number the default from A1 is to be used. This is the full and final solution for box addresses. Any corrections to that thought must be made here.
The alternative to a Box address is a street address. In the above formula that solution is represented by the place holder "street address". Below is the formula that should take the place holder's place. It's very simple, initially.
=IF(COUNTA($G3:$H3)=2,"OK","Not OK")
Observe that the cell count can only be 1 or 2. Therefore there are only two possible solutions marked by the two place holders in this formula. The formulas for these are given below. Observe that a missing street name is replaced with A3 and a missing street number with A2. The formula allows for both but, in fact, this can't occur because a Box address would be returned.
[OK] =$G3&" "&$H3
[Not OK] =IF(COUNTA($G3),$G3,$A$2)&" "&IF(COUNTA($H3),$H3,$A$3)
With the place holders replaced we get this formula.
[street address] =IF(COUNTA($G3:$H3)=2,$G3&" "&$H3,IF(COUNTA($G3),$G3,$A$2)&" "&IF(COUNTA($H3),$H3,$A$3))
And when this formula replaces the place holder "street address" in the initial, basic formula here is the final result.
=IF(OR(COUNTA($F3)=1,COUNTA($F3:$H3)=0),"P.O.Box "&IF(COUNTA($F3),$F3,$A$1), IF(COUNTA($G3:$H3)=2,$G3&" "&$H3,IF(COUNTA($G3),$G3,$A$2)&" "&IF(COUNTA($H3),$H3,$A$3)))

Excel - Match in two columns with variable names

I've got two lists of people and I have to check if they're in both lists. The thing is that characters are not accepted in one of the lists ("-" for instance), and the person might have omitted a last name in case they have two.
For example:
A1 B2
John Paul John Paul Jones
Mary Williams Ryan Roberts
Ryan Roberts-Johnson Mary Williams
My formula is: =IFERROR(MATCH($A1,$B$1:$B$1215,0),IFERROR(MATCH(LEFT($A1,FIND(" ",$A1,1)),$B$1:$B$1215,0),"No Match"))
The idea is: if the name is the same, bring me the line where the person is. If not, look for the first name and see if you find someone with this first and bring it to me. If neither works, reply with "No Match".
But apparently the Match function only retrieves exact matches, so the First Name one doesn't work.
Is there any other way to solve this?
EDIT1: First finding: I can use the SUBSTITUTE formula to replace - with space and do the search once again.
Some of the things I did to save up some time (I probably spent more time figuring out/researching than I would have if I had done ~3500 entries manually, but the learning opportunity was great.)
What I wanted:
To search for for a cell with name + surname when I only had the surname.
What I did: I remembered about the wildcards and used them with VLOOKUP:
First I got the last name and added the star: ="*"&RIGHT($A1,LEN($A1)-FIND(" ",$A1,1))
=VLOOKUP(A1,$B$1:$B$1000,1,FALSE)
And it would try and find the first one. Before that I added a check to make sure that there weren't two people with the surname (so it wouldn't throw another person there) with a simple IF(COUNTIF($C$2:$C$2000,$D219)<=2, and then the rest of the formula.
Something else that I noticed and serves as a reminder: TRIM is very important, as some of the cells had two spaces in between first name/last and some one space after the last letter of the last name. Using TRIM to create a new column made me avoid a lot of mistakes I only took a while to notice.
I believe the case is solved.
You could create a temporary column extracting the first name from B column.
See this example.

Show results only when the specific string in a cell is found and only if last character is a letter

Currently I am working with a spreadsheet where I have to collect addresses of UK business Directors. Some of the directors have multiple addresses. UK zip code consist of two segment and I have to ignore the address where the first segment of zip code starts with W1 , SW1, EC1, EC2, EC3 & EC4 and ends with character not number because those are generally industrial address. For example Please check the following addresses where the addresses starts with W1 , SW1, EC1, EC2, EC3 & EC4 and ends with letter and I have to ignore collecting those.
3RD FLOOR 207 REGENT STREET, LONDON, W1B 3HH
42, CHARTERHOUSE SQUARE, LONDON EC1, EC1M 6EU
5, WESTMINSTER GARDENS, LONDON, MARSHAM STREET, SW1P 4JA
160, QUEEN VICTORIA STREET, LONDON, EC4V 4QQ
THE BROADGATE TOWER 20, PRIMROSE STREET, LONDON, EC2A 2RS
BAKERS' HALL 9, HARP LANE, LONDON, EC3R 6DP
Also please take note the zip codes of W11,W12 W13 and so on are not prohibited and same thing applies for the SW1, EC1, EC2, EC3 & EC4.
Now as we are working on the bulk data, its impossible to notice the zip codes when collecting the address. So I have tried with combination of various formula to highlight the first segment of those mentioned zip codes in a separate column using just right after pasting the address. In this way I can see the prohibited zip codes right after pasting the address. Although I am not successful cracking on it but I was close of it. I am just sharing the thing I have tried and looking for a compact solution from you guys.
First of I have created a separate column E where it will show the first segment of the zip code when I will paste the addresses in the column D. Here is the code which I have used:
=TRIM(LEFT(RIGHT(" "&SUBSTITUTE(TRIM(D2)," ",REPT(" ",60)),120),60))
Next I have tried to show only those values which starts with W1 , SW1, EC1, EC2, EC3 & EC4 and ends with a letter. So I have created another column F and create the formula for "SW1"
=IF(NOT(ISNUMBER(VALUE(RIGHT(E2,1)))), IF(ISNUMBER(SEARCH("SW1",E2)), LEFT(E2,3), ""),"")
So if I have to check for W1 , EC1, EC2, EC3 & EC4, I have to create 5 more columns with the same formula where just have to change the value of search function. This lead me to 6 extra columns and I want a compact formula for savings the space because I generally split the browser and execl in a way that's why I can copy and paste data on the spreadsheet without minimizing the spreadsheet. This saves me a lots of time. But creating six more column will make my work more time consuming as I have to check all six columns for those zip codes.
Question - 1:
I want to ask, is there any way to make a compact formula for showing my desired result in a single column only?
Question - 2:
We also have to ignore the addresses which consist the words "floor","house" & "airport". I have tried the below formula for single query:
=IF(ISNUMBER(SEARCH("Floor",D2)), "Floor", "")
Is there any possibilities combing all required formula and show the result in one column?
Update regarding Question - 1:
I have tried to combine using some other formula to show the required result. But comes up with showing only those zip code which starts with W1 , SW1, EC1, EC2, EC3 & EC4 but can't modify it to restrict those results also where the last character is a number. Here is the code:
=IF(ISNUMBER(FIND("W1",(LEFT(E2,2)),1))=TRUE,LEFT(E2,2)&IF(NOT(ISNUMBER(VALUE(RIGHT(E2,1)))), RIGHT(E2,1),""),IF(ISNUMBER(FIND("SW1",E2,1))=TRUE,LEFT(E2,3)&IF(NOT(ISNUMBER(VALUE(RIGHT(E2,1)))), RIGHT(E2,1),""),IF(ISNUMBER(FIND("EC1",E2,1))=TRUE,LEFT(E2,3)&IF(NOT(ISNUMBER(VALUE(RIGHT(E2,1)))), RIGHT(E2,1),""),IF(ISNUMBER(FIND("EC2",E2,1))=TRUE,LEFT(E2,3)&IF(NOT(ISNUMBER(VALUE(RIGHT(E2,1)))), RIGHT(E2,1),""),IF(ISNUMBER(FIND("EC3",E2,1))=TRUE,LEFT(E2,3)&IF(NOT(ISNUMBER(VALUE(RIGHT(E2,1)))), RIGHT(E2,1),""),IF(ISNUMBER(FIND("EC4",E2,1))=TRUE,LEFT(E2,3)&IF(NOT(ISNUMBER(VALUE(RIGHT(E2,1)))), RIGHT(E2,1),""),""))))))
Your formula in column E could combine the last character is not a number with the parse of the first section of the postal code with something like the following.
=IF(ISERROR(--RIGHT(A2)), TRIM(LEFT(TRIM(RIGHT(A2, 8)), 4)), "")
That makes the parsing dependent on a British postal code being either 7 or 8 characters wide with the first section being either 3 or 4 characters. The 'wandering' space is either picked up and trimmed off or not picked up at all depending on the length.
With column Y listing the prefixes of the postal codes to be ignored and column Z (in any worksheet) devoted to a cross-reference list of exceptions like the following:
    
Note that each of the entries in the Ignore list and the Exceptions list all carry the wildcard asterisk as a suffix. This is necessary to deal with staggered lengths of the comparisons to be made.
The formula used for a Conditional Formatting Rule for A2:E999 would be,
=AND(SUMPRODUCT(COUNTIF($E2, $Y$2:$Y$7)), NOT(SUMPRODUCT(COUNTIF($C2, $Z$2:$Z$4))))
This resolves TRUE for any postal that should be ignored and is not in the exception list.
The cross-reference tables of ignores and exceptions may benefit from becoming a named range for easy reference. You could use a dynamic range definition for the Applies to: of something like:
=Sheet1!$Y$2:INDEX(Sheet1!$Y:$Y, MATCH("zzz", Sheet1!$Y:$Y))
=Sheet1!$Z$2:INDEX(Sheet1!$Z:$Z, MATCH("zzz", Sheet1!$Z:$Z))
Here's a formula to tell you whether the first word after the last comma ends with a number.
=ISNUMBER(NUMBERVALUE(RIGHT(LEFT(TRIM(RIGHT(SUBSTITUTE(B1,",",REPT(" ",LEN(B1))),LEN(B1))),SEARCH(" ",TRIM(RIGHT(SUBSTITUTE(B1,",",REPT(" ",LEN(B1))),LEN(B1))))-1))))

Separating address elements from addresses in different structures in excel 2010

I've tried finding a formula but really just can't seem to find it at all!
My problem is i have thousands of addresses in different structures but i need to find the city in each of them!
So the different types of addresses i have are as follows:
Dornocktown, Dornock, Annan, DG12 6SU
Grainshore Road, Hatston, Kirkwall, KW15 1FL
Brandon Road, Watton, Thetford, IP25 6LW
Bainbridge, Leyburn, DL8 3EP
Shore Road, Dornoch, IV25 3LS
Boston Industrial Estate, Power Station Road, Rugeley, WS15 2HS
Parkfield Road, Wolverhampton, WV4 6EH
I need the city or the last word before the post code.
Any help would be great thanks!
Try this, values in A1:A7:
In B1 write:
=RIGHT(A1;LEN(A1)-1-FIND("#";SUBSTITUTE(A1;",";"#";LEN(A1)-LEN(SUBSTITUTE(A1;",";""))-1)))
copy till B7
now in C1 write:
=LEFT(B1;FIND(",";B1)-1)
copy till C7
Now you have the city names. It is possible to do everything in one formula but will be a very big one...
Depending on your settings you may need to replace ";" by "," for field separators

Resources