Excel Macro - Find a specified value in one column and replace with all the contents of another column(the length is flexible) - excel

I have a spreadsheet with more than 3000 rows, and I want to replace specific values(v1,v2,...) in column A with the content in column B and C and ...
The length of content in column B,C,... is not fixed so it is not possible to use REPLACE function provided in Excel.
It is also impossible to edit for each row, as the content is very long.
simple example:
column A
{who} is the coach of {team}
{who} is the coach of {team}
{who} is the coach of {team}
column B
Alex Ferguson
Roberto Mancini
Rafael Benitez
column C
Man United
Man City
Chelsea
column D
Alex Ferguson is the coach of Man United
Roberto Mancini is the coach of Man City
Rafael Benitez is the coach of Chelsea
Column D is what I want(column B to replace {who}, column c to replace {team}).

Try this in column D:
=SUBSTITUTE(SUBSTITUTE(A1,"{who}",B1),"{team}",C1)
You can also do it without the "{who}" thing in column A:
=B1 & " is the coach of " & C1

Related

Excel Function - If string from column A is found in Column B Then

Column A has a list (first and last names) of all users who have an O365 license. Column B has a list of everyone in the company. Column C is associated with Column B and has the job title of everyone in the company.
I want each row in A to check all of B to see if they match. If they match I want to take the corresponding row in column C and copy/paste it into the same row in blank column D
A (O365 License
B (All Employees
C (Job Title).
D (JobTitle)
John Smith
Jarvis Cobblepott
. IT Guy
Nancy Johnson
John Smith
. Receptionist.
Kevin Gordon
Henry Kissinger
Marketing
Use ISNUMBER(MATCH()) to see if it exists:
=IF(ISNUMBER(MATCH(B2,A:A,0)),C2,"")
Alternatively maybe:
=XLOOKUP(A2,B$2:B$4,C$2:C$4,"",0)
Or:
=BYROW(A2:A4;LAMBDA(r,X.XLOOKUP(r,B2:B4,C2:C4,"",0)))

Excel - Extracting substring after a character contained in a string

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.

Sorting a data range of multiple columns

I'm currently watching about 700 videos about travel with different 80 possible categories throughout. So my idea is to have the video title in Column A. Then I have drop down menus that contain the 80 possible categories (Food, Beverage, Desert, Island, etc) in columns B through G.
So for instance
Row 1 - Column A 'Ecuador' - Column B is Food - Column C is Beverage - and Column D is South America
Row 2 - Column A 'France' - Column B is Tourist - Column C is Europe - Column D is Food
Row 3 - Column A 'Egypt' - Column B is Culture - Column C is Africa - Column D is Beverage
And so on for 700 videos.
Now the question is how could I sort or filter the videos by title to find any video that contains 'Food' if Food is found in any column B to G for that row? I want to make sure the rows stay in tact.
Let me know if my example makes sense or if I need to better illustrate the layout.
Any help is greatly appreciated!
type "search" in H1 cell, then put this formula in H2 :
=IFERROR(IF(FIND($I$1,B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2)>0,1,""),"")
and drag downwards.
To use :
Type Food in I1
Then filter for '1' in column H ("search")
Hope it helps.
note : the space is included to separate the keywords. this search version is case sensitive.
p/s : I'm only covering the " filter the videos by title.." part. Since the criteria for the sort was not defined, I'm not trying it in this solution. ( :
Another option would be to use COUNTIF:
=COUNTIF($B2:$D2,E$1)
Much like p.phidot's solution, this would go in an additional column that you would use specifically to filter the spreadsheet. You would type your search term in the header of this column.
You could nest it in an IF function to make it return "Yes" or "No" rather than numbers:
=IF(COUNTIF($B2:$D2,E$1)>0,"Yes","No")

Formula to reformat of names in excel where column A has Last, First, Middle but not always a middle

I have a column of names (column A) formatted as "Last, First, Full Middle".
However, some of the names in column A do not have a middle name (i.e. only have "Last, First" or "Last, First, Middle initial"). I'm trying to come up with a formula (or multiple) that formats the names so that column B has "Last, First, Middle initial[period]" and column C has "Last, First Middle initial[period]"
E.g., if column A has: Smith, John, David
then I want column B to be: Smith, John, D.
and column C to be: Smith, John D.
I tried the following:
in column B:
=IF(ISBLANK(A2),"",LEFT(A2,FIND("~",SUBSTITUTE(A2," ","~",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))+1)&".")
and in column c:
=IF(ISBLANK(A2),"",SUBSTITUTE(B2,", "," ",LEN(B2)-LEN(SUBSTITUTE(B2," ",""))))
Both formulas work EXCEPT if the name in column A doesn't have a middle name.
Use this in Column B:
=IFERROR(LEFT(A1,FIND("~",SUBSTITUTE(A1,",","~",2))+1)&MID(A1,FIND("~",SUBSTITUTE(A1,",","~",2))+2,1)&".",A1)
and in Column C:
=IFERROR(LEFT(A1,FIND("~",SUBSTITUTE(A1,",","~",2))-1)&" "&MID(A1,FIND("~",SUBSTITUTE(A1,",","~",2))+2,1)&".",A1)

Column A numbers matched with Column B numbers that are assigned to Column C =column D?

This is my example
Column A are numbers
Column B are numbers
Column C are Names
The A column are numbers associated with a item sold to one place. Column B is the items sold and C is the person who sold them. I would like column D to show the item sold to this one place and who sold it. Let me know if that makes sense.
PS: Column A has 1304 rows. Column B and C have 6154 rows
It is hard to guess what your data looks like, so assuming your data looks as below:
Here is my solution, I think it is a simple VLOOKUP problem:
Paste this =IF(ISERROR(VLOOKUP(C2,$A$2:$A$4,1,FALSE)),"","SoldToPlaceA") to E2 and drag it down to copy.

Resources