I googled like crazy before I came here.
I have 2 columns of information (I have to use alternate data for privacy). See below.
I would like in a 3rd column to look thru the list (or the range) of the first column and return the matching word. For example, I need the 3rd column for the first sentence (There is a cup on the counter) to say "CUP".
I've tried all sorts of combinations of functions and I can't quite get it right.
1st column 2nd column 3rd column
Desk There is a cup on the counter **Result should be: Cup**
Chair You need to plug the cord in
Cup The desk is red
Cord I have a large computer
Computer I put the chair over there
Assuming row 1 is a header row, put this formula in cell C2 and copy down:
=IFERROR(INDEX($A$2:$A$6,MATCH(1,INDEX(COUNTIF(B2,"*"&$A$2:$A$6&"*"),),0)),"")
Related
I'm fairly new to coding and i've been googling around for the last few hours trying to solve this problem but it seems to be a little beyond what i'm able to do so i would be very grateful for some help
In Sheet1, I have a table which has columns between M - CV (175 columbs). For each column, i have an "ID number" value in row 3. From Row 6 to the end of the table, i have several "search terms" separated by commas in the column CV
In Sheet2, the corresponding "ID Numbers" are in column B. Column AN contains strings.
For each ID Number value in sheet1, i'm looking to find find all the corresponding cells in sheet2 where the ID number in Column B is the same, and Column AN of sheet2 contains at least one of the "search terms" in column CV
For each ID number, i'm hoping to join the entries in Column AN of sheet2 which match the criteria above and paste them into Row 5 of the respective column in Sheet1
I've gone around in quite a few circles trying to do this and i'm back to square 1 with no code to show for it.
I've tried to research both the autofilter function, and using for loops. The research i've done indicates that for loops are rather slow to run for a large data set.
I'm hoping to find a solution which is as easy to read and understand as possible
I hope i've given enough information for everyone to understand and help
THank you in advance
My Excel subscription has expired an I've started using Google Sheets for most of my spreadsheet work, so I tested this there. Some conversion may be required. I did this using formulas, not VBA also, not sure if that changes things for you.
If I understand correctly, you have two sheets with a shared key column, sheet 1 contains search terms across multiple columns, and sheet 2 contains search terms comma delimited in a single column.
With this setup we want to bring the search term column of sheet 2 into the correct row of sheet 1 by key using VLOOKUP. I made a named range in sheets which contained all my data on sheet 2 and called it "dst". My formula was then =VLOOKUP(A2, dst, 7, true) since my key in sheet 1 was in column A, dst was the range I was searching, my column with my delimited search terms was column 7 in relation to dst, and I had ordered sheet 2 by key. I pasted this formula relatively down all rows as needed.
We want to construct a regex string using our search terms across multiple columns in sheet 1, into a single cell. I used =JOIN("|", B2:E2) on sheet 1 since my search terms were in columns B:E, and this resulted in a regex that looked like this for me: alligator|dog|rabbit|lizard where alligator, dog, rabbit, and lizard, were all search terms in that row. Paste down relative as needed.
We want to run our regex against our search target cell containing the comma delimited search terms. I ran =REGEXMATCH(F2, G2) where F2 was my delimited search terms from sheet 2, and G2 was my constructed regex for the row. Paste down relative as needed.
A screenshot of my completed sheet 1:
Once you know which cells have matches you can do whatever you want.
I have a file for Pokémon trading online where people can search for Pokémon from others active players. They are typing a Pokémon name and got the name of the player who has one to exchange and informations about the Pokémon.
In particular, when they are looking for a Pokémon, the search goes to every Pokémon that are in the same family (Bulbasaur, Ivysaur and Venusaur for exemple) using the Pokédex number of the family.
I'm trying to merge two of my formula to get ride of one column.
One of my formula give me a Pokédex number depending on the name of the Pokémon. (i.e. I have a Pokémon name and I retrive his Pokédex number in a column). This formula is pasted on all the column comparing with the cell next to his for each line.
The second of my formula, give me intel of a Pokémon line regarding a research cell by comparing the Pokédex number with the column that calculate it (with the first formula).
First fomula :
=ArrayFormula(INDEX(PokedexNumberColumn;MAX(IF(PokemonNameColumn=PokemonNameToCopareCell;ROW(PokedexNumberColumn)))))
Second formula :
=IF(COUNTIF(Formula1Column;ResearchCell)>COUNTIF(CellsBelowTheCurrentCell;"PlayerName");HYPERLINK("SheetLink";"PlayerName");"")
So like I said, the first formula is a cell to cell formula in which I got the Pokedex Family Number for the Pokemon in the line.
The second one is a bit more complex, I count how many time the research cell is in the player sheet and compare it with the amount I already displayed. If I need more diplay, I put it. If not, nothing.
What I expected is to merge the two formula to be able to get ride of the column with the first formula, because the file is shared online and often people damaged the formula by adding or deleting some lines.
EDIT : I create a file simplified of my problem : https://transfernow.net/ddl/PokemonLists
In the Search Option Tab we have:
In Blue, you have the cell of research where you choose the name of the Pokemon you're looking for. In Orange are the formula I used, first the family number of the Pokemon searched in order to look for any other Pokemon of the same family. And then the two others cells in orange are just the results.
In the Pokedex Tab we have only intels to which make reference when we're making a research, name of Pokemon and Family Numbers.
In Player1 Tab, we have the list of Pokemon that the player one can exchange, with in Orange the famous Formula I want to erase by putting it directly in the first Tab Formula. This formula goes into the Pokedex Tab to find the Family Number of the Pokemon and display it.
So if you're going into the first Tab and select a Pokemon in the blue cell, you will have a result if the pokemon or one of its family is in the list of the player one. It's the case for option 4 to 9, not 1, 2 and 3.
I don't care about merge formula of the first tab as it's always protected except the search cell. What I need is to erase the formula of the player tab in order to avoid problem when they add or delete lines.
Thank you !
Currently, I am working with a scenario where I have 0 to 6 names in the field. For example, A2 has Bob Smith and Jone Random. Below is an example how they look in a check.
Effi Liu
<- (enter/gap)
Kevin Xing
Basically, I want to generate a 1 column that counts how many people in A2. For example, two people and then create a function that will separate. Each of the names into different columns.
If you have the names separated by the Enter Key in Column A, use the below formula in Column B and drag it to the right upto 6 or more cells and then drag down,
=TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1,CHAR(10),"#"),"#",REPT(" ",999)),(COLUMN(A:A)-1)*999+1,999))
This formula splits your name strings with the Enter Key as the delimiter into multiple columns as you drag. You could then use COUNTA function to find the non-blank cells (number of names). I leave that part to you to google and find it. Hope this helped you.
I have data in two columns:
a 1
a 1
a 2
b 3
b 4
In the list there is 4 unique rows. I would like to ad a unique id to each unique row.
Like this:
1 a 1
1 a 1
2 a 2
3 b 3
4 b 4
Of course I have many more rows and columns and date are more complex than in this example.
Anyway to do this i excel?
Mvh Kresten Buch
I have the same issue, I have developed a three formula approach to this. I could probably concatenate it if I nested them, but whatevs, this works.
Assume the data you want to 'number' is in column A, and the first row of the table is row 3.
The first column (in column B) counts occurrences of the 'value' and the range expands from the top of the table downwards as the table grows:
=COUNTIF($A$3:A3,A3)
the second column's formula also expands as the row count does, and simply adds 1 to the transaction count every time it encounters a 1 (ie first occurrence of a new unique value) in column B
=IF(B3=1,MAX($C$2:C2)+1,"")
This one worked for me even in the first row of the table btw - i was expecting to have to manually input a 1 to start the list. Having it work without the manual entry is a good thing, it means the formmulas all work even if you resort the table data into a different order.
The third one in column D uses a vlookup to find the value. Note that when vlookup finds more than one number, it always pulls the first occurrence.
=VLOOKUP(A3,$A$3:C3,3,FALSE)
Note that this will renumber all the data outcomes dynamically if you do resort the entire thing. ie the formulas all work, but the number 'assigned' to a praticular set of data might be different, as it all works from whatever order the list of items is in.
My use case for these formulas assumes that every month i paste a new set of data to the bottom of the table, some items of which are repeats from previous months - ie are already in the table, and some of which are new.
if the dynamic renumbering is a problem, use a 'row key' so you can resort back to the original order at the end.
Assuming your data is in B2:C6 please try =IF(AND(B1=B2,C1=C2),A1,A1+1) in A2, copied down
If your data is not sorted, it's more complicated... but you can use something like this in A2:
=IF(COUNTIFS($B$1:B2,B2,$C$1:C2,C2)>1,INDEX($A$1:A1,IFERROR(MATCH(B2&"-"&C2,$B$1:B1&"-"&$C$1:C1,0),1)),MAX($A$1:A1)+1)
I'm assuming that there are no headers and you have already put 1 in cell A1 for the first record.
It basically checks the whole columns above the formula and if there's already a similar record, it'll assign the previously given unique ID and if not, it'll give a new ID.
This is an array function and as such will work if you use Ctrl+Shift+Enter and not Enter alone.
The IFERROR() is there because MATCH(B2&"-"&C2,$B$1:B1&"-"&$C$1:C1,0) would return an error if it is on row 2 (the first record to check).
Once you put that in the first cell, you can fill down the formula.
I deal with this issue all the time when structuring a data set into panel data. say you have multiple columns of data, and each are unique based on the name of someone, like:
ANNE
ROSE
ANNE
FRANK
TOM
ROSE
ANNE
but instead of having each column related to Anne, Rose, Frank, or Tom, you want it to look like this:
1 ANNE
2 ROSE
1 ANNE
3 FRANK
4 TOM
2 ROSE
1 ANNE
So that each name now has a unique numerical identifier that can be used in place of the name.
Make a pivot table of your data and only place the column that has the names (or whatever the identifier may be) into the Rows section. This will single out all the different names used within the dataset. Copy and paste this pivot table anywhere on the sheet so that the names are in actual cells and not off of a pivot table. To the right of the names, enter 1 next to the first name, and then =B1+1, and so on so that you number each name with a unique value; then copy and paste this column as numbers so that their formulas are erased. Finally, just go to your original dataset and perform a VLOOKUP so that the names get attached with whatever unique value was assigned off of the pivot table. Make sure to copy and paste as numbers once done to remove the VLOOKUP formula.
Takes literally 2 minutes to do, depending on size of dataset, and is very easy. It will work perfectly every time.
I have two columns, the first column will have the name of a object, the second is who it belongs to. I want a new sheet for each person to list what they had assigned to them. here is a example:
dog F
cat F
bell S
whistle
bird F
So Fred has a dog, cat, and a bird; Scott has a bell; and no one has a whistle on their page. Now doing a simple IF() i can get it to look like this for Fred's page
TOP OF ROW
dog
cat
bird
And Scott's page will look like
TOP OF ROW
bell
however I want Fred's to look like
TOP OF ROW
dog
cat
bird
and Scott to be the same.
My current train of thought is to use =VLOOKUP($C$1,Items!A2:C1000,3) in a hidden column in D to tell me which row my data is in, (where Column C on Items is a hidden column with the row number of the row and C1 is the search parameter (S or F)), then =IFERROR(CELL("contents",INDIRECT(ADDRESS($D2,2,1,TRUE,"Items"))),"") , however I other than changing my row index of my search array to 1+ the last found item (which i have not figured out how to do) I can not figure out how to continue searching for the next item.
I know C++ and C# but never have coded in VBA before and I rely heavily on the MSDN and to my knowelge there is no MSDN section dedicated to the Excel API.
One way of achieving the list that you are looking for without any VBA code is to make use of the advanced filter.
On sheet 1 the input list is entered as follows
on sheet2 enter the filter criteria (this criteria means contains F in Owned by column)
and finally on sheet3, call the advanced filter function like this
make sure to select copy to another location
select the sheet1 input list as the list range
select the sheet2 filter criteria as the criteria range
and select somewhere in sheet3 as the output range (the copy to entry)
If you prefer to go down the route of excel VBA programming a good first step is to try out the macro recorder in excel (tools - macros - record macro)
good luck!
There is a good way of doing this with functions in excel.
Essentially you need to create a running countif
So in C2 you would have =COUNTIF($B$2:$B2,"F") Obviously the "F" could also be a reference to another cell. If you fill this formula down the range it will expand the range. Eg. in C3 it will say =COUNTIF($B$2:$B3,"F")
This will give you a running total in column C in your example this would mean:
dog F 1
cat F 2
bell S 2
whistle 2
bird F 3
The fact that you have 3 2s doesn't matter because a vlookup will always match to the first match it finds.
This technique has a lot of different applications. And depending on the data you may find it easier to put this on the left of the data so the VLOOKUP will be easier.