Excel if statement - excel

Trying to make this scenario work -
Have to reference a range of cells in a column in another work sheet and if the values are like new york 4th street it must populate as new york or must populate the default value.
=(IF(Dashboard!GT14=New York - C4) , New York , Dashboard!GT14) - this does not work
couple of other scenarios also do not work
Suggessions welcome

First, New York should be "New York".
And what is C4 ?
For example, if C4 is "Boston" and you want to know if GT14 is "New York Boston", you have to put GT14 = CONCAT("New York ";C4)

Something like this?
=IF(ISNUMBER(FIND("new york",LOWER(Dashboard!GT14))),"New York",Dashboard!GT14)
assuming you have a full address in GT14 and that you want to check if New York is part of that.

Related

Excel formula: search in column by another value (LIKE)

I'm having a problem in Excel, where I'm trying to search an entire column for a name (not necessarily 100% identical) that is in another column.
The following table for a better explanation:
---------------------------------------
NAME CITY FATHER NAME
---------------------------------------
Saad Test New York William Jack
Jack Jacking Paris Noah Saad
Adam King Rabat William Sara
Sara Best Madrid Benjamin Adam
Briefly: I want to get the father's name by using only the name column. Is there a way to do that? (The order of the fathers’ names is incorrect, so I want to search using the name, if it is present in the father’s name, then it is the result I want)
Example: Saad test his father's name is Noah Saad (Match by Saad)
PS: I tried using LOOKUP, VLOOKUP and MATCH, but unfortunately the result is always N/A
PS 2: The data I have in Arabic is the reason why the above functions are not working?
I would use index() with match(), assuming your data starts in cell A1, like so:
=index(C1:C4,match(F1,A1:A4,0))
F1 contains the name that you look for.
Note, the classic problem is that there are extra spaces (leading or trailing) that make the names not identical.
You can trap errors as so:
=iferror(index(C1:C4,match(F1,A1:A4,0)),"Check")
You could do:
=INDEX( $C$2:$C$5, MATCH( "*" & MID( A2, 1, FIND( " ", A2 )-1), $C$2:$C$5,0) )
SolarMike - I think you have said the same, so I'm sorry if I am
stepping on your answer.

Find the position of a related string in a list

In my worksheet, B2:F2 and B8:D8 are already filled in.
I would like to find the formulas for B9:D9. For instance, B9 is 2 because we can find Lee in Lee XXXX and Lee is at the second place of B2:F2. C9 is 4 because we can find Jim in Jim XXXX and Jim is at the second place of B2:F2.
To check the relation of Lee and Lee XXXX (Jim and Jim XXXX), we could use SEARCH, left_substring (if such a function exists).
Both single formulas or array formula will be fine. Using LAMBDA function is secondary choice, because it is still in preview.
Could anyone help?
If what is needed is always the first "word":
=MATCH(LEFT(B8,FIND(" ",B8)-1),$B$2:$F$2,0)
If you want to search on any position in the string:
=AGGREGATE(15,7,(COLUMN($B$2:$F$2)-MIN(COLUMN($B$2:$F$2))+1)/(ISNUMBER(SEARCH(" "&$B$2:$F$2&" "," "&B8&" "))),1)
With FILTER instead of AGGREGATE:
=#FILTER((COLUMN($B$2:$F$2)-MIN(COLUMN($B$2:$F$2))+1),ISNUMBER(SEARCH(" "&$B$2:$F$2&" "," "&B8&" ")),"")

how to extract string based on this manner in excel?

I want to extract only these words if present in a cell:
{Beijing, New York, Japan}
I have a column with the following data(rowwise):
Nice city- Beijing, Awesome climate
Fair city- Japan, Cool weather
New York is so nice
All i want is another column which will have:
Beijing
Japan
New York
Is it possible to do it without vba?
Is there any formula? I have nth entries rowwise
You can try:
=LOOKUP(2^15,SEARCH({"Beijing","New York","Japan"},A1,1),{"Beijing","New York","Japan"})
You could use a formula such as
=IF(IFERROR(FIND("Beijing",A1),0)=0,"","Beijing")&
IF(IFERROR(FIND("Japan",A1),0)=0,"","Japan")&
IF(IFERROR(FIND("New York",A1),0)=0,"","New York")

Search for a specific word stored in one column which has so much data

I have a free text column full of contact details. I want to extract realtion ship out of the contact details. I tried different formulas, but didnt work. Even I have added a column with relationship status and tried
=INDEX(D$2:D$5,MATCH(1,IF(ISERROR(SEARCH(D$2:D$5,A2)),0,1),0),1)
but it didnt work.
For ex:
Contact Details Column:
Matthew Brown: Wife: 937268475663 (home) or 939848399384 (mobile)
Bill Benoit: Father: 7494785736784
Spouse - Matha Nocon - 948479 289374
Mrs Elaine Batty: Wife: 29474567334
Iain Beveridge020 8877 3537
Janice Waddy01482 581000 Work 07986501322 Mobile
Tony Salter (Father)Tel: 0207 583 5000
Mrs Amanda Bluff - 01507 466198
Paula Washburn[Sister] - 87362 741895 [Home]
Cliff Potter (Husband) - 0263 88472363(Work)
I want an excle formula that searches relationship from ralationship status column inside the contact details column and extract relationship (wife, husband, etc.).
Hi Kaliakanhu Panigrahi,
You use array in your formula and you forgot put it on {}.
You can do it by pressing Ctrl + Shift + Enter when you are in the formula cell.
When I did this it works fine for me.

Cleaning data using macro

If possible, I need help with creating excel macro which will clean some fields in my spreadsheets.
I am receiving excel spreadsheets with different amount of records. And in the following spreadsheets I need to format fields like First Name / Last Name / Job Title / City (I used excel Proper() function when I did it manually). Most important, I need also to replace Industry field with the standard values from another sheet. And: to replace State (from short values, like TX to Texas), also replace Country from us or usa or united states of america to "United States". (when I performed this manually, I used VlookUp () function).
Example:
I have spreadsheet(s), like:
Sheet 1, Data:
FName LName Email Title City ST Phone Industry Country
John sm j#hotmail.com it dallas TX 5556663344 mobile us
jess lee jess#aol.com ba ny ny 6667775656 art usa
nick Jahn nick#aol.com ba raleigh ny 444-3338888 tech us
Sheet2, State:
ST ST_Full
TX Texas
NY New York
NC North Carolina
etc. -> all US / Canada states list
Sheet 3, Industry:
Industry Industry_Correct
Mobile Telecom
Art Other
Tech Technology
etc. -> the list of all possible variations correct/incorrect industries
Sheet 4, Country:
Country
Angola
Canada
Russian Federation
United States
for the Sheet 4, I have alphabetical list of over 200 countries, and need to replace countries like "us" "Russia" to proper name from the list.
Result Sheet, (what expecting to have):
FName LName Title City ST Phone Industry Country
John Sm It Dallas Texas 555-666-3344 Telecom United States
Jess Lee Ba New York New York 666-777-5656 Other United States
Nick Jahn Ba Raleigh New York 444-333-8888 Technology United
States
email
j#hotmail.com
jess#aol.com
nick#aol.com
I was trying to record very simple macro; but I have very different spreadsheets - w. different amount of records - from 5 to 2000 or 3000 records.
Simple recorded macro only somehow cleaned FIXED amount of records.
It sounds like you have your recorded macro working properly except that it is working on a fixed amount of records. You need to make the range dynamic so your macro can see how many rows of data there are automatically. Without seeing your code, its hard to tell you how to implement this. Generally, something like this will do the trick:
Dim sht As Worksheet
Dim LastRow As Long
Set sht = ThisWorkbook.Worksheets("[sheet name]")
'Can also reference the sheet code, which is better in my opinion. Set sht = Sheet1 or whatever number your sheet is.
'This will fetch the last row for you
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
You may find this website helpful: http://www.thespreadsheetguru.com/blog/2014/7/7/5-different-ways-to-find-the-last-row-or-last-column-using-vba
To respond to your comments:
You should implement this at the very beginning of your code. So what we are doing is 1) setting the sheet for the macro, 2) determining the last row of data in that sheet, and 3) you need to then use that last row to set a Range for the macro to work on, or at least go through your macro and replace row 1000 with LastRow. So, in addition to the code I provided, you may also have something like:
Dim myRange as Range: Set myRange = sht.Range("A2:Z" & LastRow)
Then you can simply reference myRange when you need your macro to do something in that range. Hope that helps. Instead of make a new post, you should be able to edit your original post to add some of your code if necessary.
As to your IFERROR question, its hard to say the most correct approach without more information. Generally speaking, I think its better to use if/else statements, but you can certainly just use WorksheetFunction.iferror(...) if you need to replicate the same iferror functionality that is built into Excel.

Resources