Excel - Extracting substring after a character contained in a string - excel

I am trying to extract partial string contained within a cell after a certain character in the string.
I have a formula which can do this
=RIGHT(C10,LEN(C10)-SEARCH(":",C10))
But let's say the location of C10 cell isn't exactly known within the C column, and a way to locate it is by searching for a keyword in column D and then extracting the partial string using the above formula to a cell next to the keyword (column E).
I hope this makes sense.
Ex)
Column C
John: 1234 Alphabet Street
Claire: 3456 Diamond Street
Tim: 333 Laugh Lane
Bo: 5555 Great Neck Street
Grace: 777 Whiteside Blvd
Column D
John:
Claire:
Bo:
Thank you.

You could use:
=TRIM(SUBSTITUTE(VLOOKUP(D1&"*",C:C,1,0),D1,""))

This approach should work for you. First, modify the formula as below for the first row in E (i.e., E2)
=IF(ISTEXT(D2),RIGHT(C2,LEN(C2)-SEARCH(":",C2)),"No address found.")
In order to apply this formula throughout for the column triplets C, D and E do the following: Click on the top-left corner of column 'C', hold and drag the cursor towards right to include columns D and E and now drag all the way down to the last row of C, D and E. Now, the formula is automatically applied to all the rows viz. C, D and E.

Related

Formula to get crossed values

I am trying to get values from other column, based on some logic, crossed logic, but I didn't get any result with the only thing I know: IF or VLOOKUP.
The table is in this way:
So basically there are groups divided by blank row, and in column D I want to add the value from column B, but according with other letter that the one from the row ( C is from Credit, D is from Debtor). So in first D5 I have C on the same row in A5, so I need to take value from D, which is 2, according to B6.
So sorry if this question is too easy or stupid, but I don't know much about excel formulas, other that the basic one.
I'd say the fastest way with formula takes two columns. The first one (let's say column C) will use this formula to define the blocks:
=IF(A5="",C4+1,IFERROR(C4+0,0))
It's meant for cell C5.
The second column will give back the actual result:
=SUMIFS(B:B,A:A,IF(A5="C","D",IF(A5="D","C","")),C:C,C5)
It's meant for cell D5.
Place them accordingly and drag them down to cover your list.
Then again: if you are looking just for the number and not for its sum (and therefore assuming all numbers are equal for each letter in each block), just use this one in cell D5 instead of the previous one:
=SUMIFS(B:B,A:A,IF(A5="C","D",IF(A5="D","C","")),C:C,C5)/COUNTIFS(A:A,IF(A5="C","D",IF(A5="D","C","")),C:C,C5)
Now if you were to use only IF and VLOOKUP functions, a possible solution could be this one:
A
B
C
D
E
F
G
Block index
0
What to search
What is
Value
Result
C
1
=IF(A5="",C4+1,C4)
=IF(A5="",C4+1,C4)&SE(A5="C","D",SE(A5="D","C",""))
=C5&A5
=B5
=IF(VLOOKUP(D5,E:F,2,FALSO)=0,"",VLOOKUP(D5,E:F,2,FALSO))
D
2
=IF(A6="",C5+1,C5)
=IF(A6="",C5+1,C5)&SE(A6="C","D",SE(A6="D","C",""))
=C6&A6
=B6
=IF(VLOOKUP(D6,E:F,2,FALSO)=0,"",VLOOKUP(D6,E:F,2,FALSO))
D
2
=IF(A7="",C6+1,C6)
=IF(A7="",C6+1,C6)&SE(A7="C","D",SE(A7="D","C",""))
=C7&A7
=B7
=IF(VLOOKUP(D7,E:F,2,FALSO)=0,"",VLOOKUP(D7,E:F,2,FALSO))
=IF(A8="",C7+1,C7)
=IF(A8="",C7+1,C7)&SE(A8="C","D",SE(A8="D","C",""))
=C8&A8
=B8
=IF(VLOOKUP(D8,E:F,2,FALSO)=0,"",VLOOKUP(D8,E:F,2,FALSO))
D
3
=IF(A9="",C8+1,C8)
=IF(A9="",C8+1,C8)&SE(A9="C","D",SE(A9="D","C",""))
=C9&A9
=B9
=IF(VLOOKUP(D9,E:F,2,FALSO)=0,"",VLOOKUP(D9,E:F,2,FALSO))
C
4
=IF(A10="",C9+1,C9)
=IF(A10="",C9+1,C9)&SE(A10="C","D",SE(A10="D","C",""))
=C10&A10
=B10
=IF(VLOOKUP(D10,E:F,2,FALSO)=0,"",VLOOKUP(D10,E:F,2,FALSO))
=IF(A11="",C10+1,C10)
=IF(A11="",C10+1,C10)&SE(A11="C","D",SE(A11="D","C",""))
=C11&A11
=B11
=IF(VLOOKUP(D11,E:F,2,FALSO)=0,"",VLOOKUP(D11,E:F,2,FALSO))
D
2
=IF(A12="",C11+1,C11)
=IF(A12="",C11+1,C11)&SE(A12="C","D",SE(A12="D","C",""))
=C12&A12
=B12
=IF(VLOOKUP(D12,E:F,2,FALSO)=0,"",VLOOKUP(D12,E:F,2,FALSO))
C
5
=IF(A13="",C12+1,C12)
=IF(A13="",C12+1,C12)&SE(A13="C","D",SE(A13="D","C",""))
=C13&A13
=B13
=IF(VLOOKUP(D13,E:F,2,FALSO)=0,"",VLOOKUP(D13,E:F,2,FALSO))
C
5
=IF(A14="",C13+1,C13)
=IF(A14="",C13+1,C13)&SE(A14="C","D",SE(A14="D","C",""))
=C14&A14
=B14
=IF(VLOOKUP(D14,E:F,2,FALSO)=0,"",VLOOKUP(D14,E:F,2,FALSO))

Compare user input to two columns and return value from 3rd predefined column

So I am trying to understand how to use excel to complete this exercise.
Basically, I have 4 columns (A, B, C, D). Looks like this:
A B C D E
CRT Carrot CRT CR
Apple Apple APL AP
Basically, I need to scan down column A and compare it to columns B & C. If the word in A matched either the full word in B or the three letter word in C, then I need to take the two-letter word in D and write it in column E.
I've managed to Use VLOOKUP to scan column A and column C and then append to E, however, I can't figure out how to have excel scan both B & C and then append D to E. (main issue here is that the input in A sometimes matches B and sometimes matched C).
Thanks!
I don't have a full grasp of your issue but have you tried aggregating the conditions in other columns like
Have column G Boolean check if A matches a word in B
Have column H Boolean check if A matches a three letter word in C
Have column I = G OR H
then have your result column based on I?
For what you are trying to achieve you can do with a nested if statement:
In Cell E1, use this fromula:
=IF(A1=B1,D1,IF(A1=C1,D1,""))
With the cell still selected, on the bottom right of the cell you will see a small square, click on this small square and drag down to auto-fill all the cells as required.
Formula: =IF(IFERROR(MATCH(A1,B1:C1,0),0)>0,D1,"")
Results:

Splitting addresses into columns in Excel

I need help splitting addresses into columns in Excel.
Addresses in COLUMN A are written like:
601 W Houston St Abbott, TX 76621 United States
13498 US 301 South Riverview, FL 33578 United States
COLUMN B is actually a helper column. It contains only the city names from COLUMN A. My idea was to somehow match COLUMN B with COLUMN A and then all matches move to another column. That would separate City from the Address.State, Zip and Country I can use "split text to columns" since "comma" is delimiter. But I need help splitting address and the city.
There is a "comma" right after the city name, but some cities has more than one word in city name.
What I need to do is split the addresses like it's highlighted in green in the image below.
What is the best way to do that in Excel? What would be the formula for that?
We can use a quirk of LOOKUP to get this working.
=LOOKUP(1E+99,FIND(B$2:B$100,A2),B$2:B$100) in D2 will return the city based on searching for matches in column B. Note that this will need the full range of column B specified to be filled.
Then we can put =LEFT(A2,FIND(D2,A2)-2) in C2 to get the first part of the address.
The rest is easy if we can assume that the state, Zip and country are of constant length (if you've got any addressses outside the US then you'll need to alter this):
=LEFT(RIGHT(A2,22),3) in E2
=LEFT(RIGHT(A2,19),5) in F2
=RIGHT(A2,13) in G2
Since you already have City in Col B, just replace the city in A
D2 =SUBSTITUTE(A2,C2,"")
Column C Paste special values in Col C
Split Column C using comma.
Then split the Column D using "space". Assuming you have all records in US, you can add the country to all rows if required.
EDIT
I missed that the city name in the row does not correspond to the address. To match the city from the Master, you can use this array formula:
C2 =INDEX(B:B,MATCH(1,MATCH(""&$B:$B&"",A2,0),0))
Array formula must be confirmed with Ctrl-Shift-Enter.
However, this will find the first match. If you have cities Foster & Foster City in your master, Foster City wlll never be matched. So, sort the cities in descending order of length.
Once you have the City name matched you can follow the steps I gave earlier. Note that I have adjusted the formula to take into account the city name that has been matched by this new formula.
So, it is possible to get it done with the formula. It may not be the best way, but I got what I needed.
I've added a new sheet and named it "cities"
I moved the city list from sheet 1 to COL A in sheet "cities"
In sheet 1, B1 = =INDEX(cities!$A$1:$A$10000;LOOKUP(99^99;MATCH(RIGHT(TRIM(LEFT(SUBSTITUTE(A2;",";REPT(" ";255));255));ROW($A$1:$A$100));cities!$A$1:$A$10000;0)))
Then I've simply use SUBSTITUTE to remove city names from column A in Sheet 1: C1==SUBSTITUTE(A1, B1, "")
And that's it!

In Excel I have two columns that equal a third column but they don't equal each other. How do I get them to equal each other?

In Excel I have two columns that equal a third column. How do I get the first two to correspond to each other? Listed below is a small example. Sorry I didn't know to properly paste the Excel into this post. As you can see I have Columns A-E with the titles UPC, Barcode, RMSID, UPC and Barcode. Columns A and D are the same value of a UPC. Both B and C correspond to the UPC column or A and D. I want B and C to correspond to each other since they both share the value of A or D. So if C and D correspond to each other then B does also and I want this to show in Column E. How do I write this in Excel?
A B C D E
UPC Barcode RMSID UPC Barcode
834135001034 102432 883 892773000857 105422
892773000864 105423 884 818780010016 106487
892773000604 105421 888 892773000864 105423
892773000857 105422 900 892773000604 105421
818780010016 106487 910 834135001034 102432
ok, this looks like a straight forward Vlookup or index/ match. In E2 place the following formula:
=Vlookup(D2,$A$2:$C$6,2,0)
D2 is what you are looking up in the first column of A2:C6 where C6 is the bottom right corner of your data. the 2 tells the formula to return the value in the second column. the 0 or false tell the formula to find an exact match for what you are looking for.
you could also do this with an INDEX/MATCH combination. It tends to be preferred as vlookup only looks up information in the left most column and can only return information to the right. INDEX/MATCH does not have to line up vertically and the columns (or rows if you are doing horizontal lookups) can be in any order. I would use the following:
=INDEX($B$2:$B$6,Match(D2,$A$2:$A$6))
Match will tell you what postion from the top of the A2:A6 column the value in D2 was found. Index will then use that value to return the value in the same position from the top in column B2:B6.
When something is not found its going to spit out and error. You can deal with that error using the IFERROR function and either have it return some text to let you know, or return an empty cell with "". Here is one example:
`=IFERROR(VLOOKUP(D2,$A$2:$C$6,2,0),"Not Found")

SUMIF a cell on the same row, in a certain column, contains a specific text

I'm trying to sum all transactions on a spreadsheet of my bank statement. Let's say I have the following under columns B-F:
B C D E F G
Date Type Transaction Value Balance ???
row 4 23/05/14 BAC Bank transfer A 1103.55 637.03
row 5 23/05/14 POS Pizza purchase 10.00 627.03
row 6 23/05/14 POS Coffee purchase 10.00 627.03
I'd like to make a new cell on column G which sums all values in column E that are on rows containing "POS" in column C. Is this possible?
Yes and I believe the simplest way is by using SUMIF:
=SUMIF(C:C, "POS", E:E)
In other words, sum E:E if C:C equals "POS".
=SUM(IF(C4:C6="POS",1,0)*E4:E6) is one way. Expand the ranges to taste.
Note this is an array formula: you need to press Ctrl + Shift + Return once you're done editing.

Resources