Need to do a custom search in excel - excel

In one sheet I have a database of companies. But the problem is that there are some companies (row items) which I don't need. Now, in a separate sheet I have filled the first column with junk words and phrases. These junk words are keywords in the "Business Name" column in the database sheet.
So I want to filter the database sheet by the first column (Business Name) if one of the keywords in the junk column is present in the name.

This is not a total answer, but in essence part of the solution. I think you may need to resort to something like a VBA macro/script for this. I did this in GoogleSheets. Excel works the same for iferror and find. If the cell D5 is 0 then you don't have a match. Any positive value would be something you'd want to include.
So presuming you could get this to work, you'd run a macro and in column B put a 0 if D5 was 0 otherwise place a 1. Then you could filter on column B for the '1' or just omit 0 and not bother to map 2,3,4 etc to 1.
Formulae
Result for A2 only
If that can be merged into a VBA script that spins thru each row and grabs column A you'd have your answer.

Related

Using two values in a sheet to filter and return values from a table in another sheet

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 want to index specific values in a specific range

I have a list of students that I have the following mark criteria,
from 0 to -500
from -501 to -1000
from -1001 to -5000
from -5001 to -10000000000
The list of students and the categorization were on sheet 1. On sheet 2 I have the criteria as headers.
I want a formula that I can use under lets say criteria 1
and it automatically fills all the account numbers that met the criteria under the column that has that criteria as a header.
Sheet 2:
You can use this array formula (ctrl+shift+enter !!) :
{=IFERROR(INDEX(A$1:A$5;SMALL(IF((B$1:B$5>-1000)*($B$1:$B$5<=-500);ROW(A$1:A$5)-ROW(A$1)+1);ROWS(A$1:A1)));"")}
I hard coded the cut-off values, but this would be better of course with a reference to the cells above where you put the cut-off values (so you not only can copy down, but also copy right). In A$1:A$5 are the students/accounts, and in B$1:B$5 their scores. You can copy this formula down in each target column, ideally as far down as there are rows in your original list (just to cover the --probably unlikely-- case that all students' scores are in the same bracket...)
Of course change the ; delimiter with , if needed according to your regional settings.
Credit to this answer on SU : https://superuser.com/a/692580/681891
A quick solution would be to enter all your data into each column, and then sort by your criteria. Each column would contain all the data, but only display the desired fields.
No VBA necessary.

Checking to see if two rows have similar data in excel

I want to compare data in two excel cells (from two columns) and write the matching values only to third column.
I have two lists of countries, column B has roughly 120 countries while column A has roughly 192 countries. I can't figure out a way to display the countries that correspond with each other (seeing if B belongs in A).
Here is an example of what I pulled off from another thread and it doesn't work for me.
excel question
Now, here is my spreadsheet.
My spreadsheet
I just want to validate and compress the countries that are listed in column B to see if they match Column A and print them in C.
Please let me know how I would do so?
Thanks,
You can use this formula in cell C1 and drag down as far as necessary.
= IF(SUMPRODUCT((B1=A$1:A$192)+0)>0,B1,"")
This formula returns the country name in the cell next to it if the country exists in the A column, and blank otherwise.

EXCEL: How to merge 2 sets of customer data

I am sure this question has a really easy answer, but after extensive research I have somehow not found what I was looking for. I am not an excel pro, but do have some experience with it.
Basically I have 2 sets of data that is indexed by customer account number and gives certain values, such as sales, profits, costs etc in the one file and sales rep responsible, amount of times contacted in the other file.
My goal now is to get these two files into one, so that I have the customer ID in the first column and all the data respective to that customer number in the columns next to it on one sheet.
However the customer numbers from the two sheets are not sorted in any way so I cant just copy and paste it and i am dealing with quite a large data set so I cannot just do it manually. additionally there are more customers id's in the first sheet than in the second, since some data is missing for a certain amount of the customers.
How can I basically automatically merge the data belonging to each customer so that it ends up being displayed in one row?
I recommend that you approach the merging of these two lists by creating a 3rd, comprehensive listing, which pulls from your raw data files.
Setting up your new Results Sheet
Assume that one list is in Book1, sheet1, and the other list is in Book2, sheet1. Open up a new excel file. Put the headers along the top. Next, you will create an index which shows all unique customer ID numbers, sorted by number. This will only work if there are no duplicate ID's (except for the ones which refer to the same cusotmer).
Copy the Customer ID column manually from Book1 into the New book. Copy the customer ID's from Book2 manually, underneath the Book1 customers, in the same column in the New book. Highlight the customer ID column. Go to the Data ribbon, then Remove Duplicates. Then rightclick your data and click 'sort'. This will leave you with an ordered customer ID column, and all other fields under the other headings will be blank.
Vlookup Formula
Next, you will use 2 vlookup formulas, similar to what #StaceyBurns recommends below. Vlookup takes a specific unique value, and looks for that value on the leftmost column of a datablock. Then it finds the first time there's a match for that value, and returns a value from a cell on that row, a given number of columns away. So for example:
=VLOOKUP(A1,B1:D5,2,FALSE)
Says: Take the unique value found in A1, look for that value in column B, from row 1:5, and return the 2nd column's result out of the datablock B:D (column C). So if A1 was the same as B3, this formula would provide the result for C3. FALSE means it would try and approximate your value if there's no match.
Assume customer indexes for all files are in column A. Assume also that all other headers are in the same order, let's say from A1:H1. Your formula to use VLOOKUP in the new workbook would be as follows - put this in B2:
=VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,column(),FALSE)
This gives you the matching amount under Sheet1's column B header, where Sheet1!'s customer ID matches the customer ID shown in cell A2 of the New book. However, we need to know whether it was able to properly pick up a value from Book1 - because we know that some data is incomplete. So, let's check if the above result is either a number, or text:
Determining if Results are found in Sheet1
=OR(ISTEXT(VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE)),ISNUM(VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE)))
This will return TRUE if the result is either a Number, or Text. So it will return FALSE if either no match is found for that ID number on Book1 Sheet1, or if the result is a blank cell. So now we put that inside of an IF statement - if it returns true, we want the result from Book1. If it returns false, we want to attempt to pull the result from Book2, through the exact same formula. This whole thing will look like this:
Final Formula
=IF(OR(ISTEXT(VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE)),ISNUM(VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE))),VLOOKUP($A2,[Book1.xlsx]Sheet1!$A:$H,COLUMN(),FALSE),VLOOKUP($A2,[Book2.xlsx]Sheet1!$A:$H,COLUMN(),FALSE))
Now, it will try to find the match from Book1 - if there's no match for the ID, or if the match returns a blank value for that header, then it will try to find a match from Book2. If it finds no match there, it will return #N/A! (which shouldn't happen, because that means you've deleted one of the customer ID's that we pulled directly from Book1 & Book2). It might return a blank cell if that data piece is not in either sheet. This formula can be copied from B2 all the way to the bottom right of your data block in your results sheet.
You can use the VLOOKUP function on the first sheet to bring the data from the second sheet in.
So for example, take an empty column on your first sheet and add the VLOOKUP function which looks like this:
=VLOOKUP(cell to lookup,
set of data on 2nd file,
column index on 2nd file of data you want,
TRUE/FALSE Boolean to ask for either close match or exact match )
If your Customer ID is in column A and your second sheet looks like this:
A1 Customer ID
B2 Sales Rep
C3 Number of Times Contacted
then you would do a look up first for the Sales Rep:
=VLOOKUP(A1,Sheet2!$A$1:$C$15,2,FALSE)
Then double click on the bottom right corner of this cell to populate the formula for all your rows.
Then do the same in a new cell for the Number of Times Contacted:
=VLOOKUP(A1,Sheet2!$A$1:$C$15,3,FALSE)
(Note I used C15 as an example in the above VLOOKUP. It should be the number of rows you have on file 2)
More info:
https://support.office.com/en-us/article/VLOOKUP-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1

How to single out unique records in the whole spreadsheet?

In EXCEL 2010 I have 2 columns which contain email addresses. I need to find those which are present in the entire spreadsheet (in both columns) only once and single them out, meaning if one record is present in column 1 and 2 then delete both records leaving only those which never appeared more than once. Any ideas ?
PREPROCESSING
Put them all in the same column. Use LOWER() if necessary to make sure they're all the same case. Use TRIM() if necessary to remove extra spaces. Sort them (not necessary with COUNTIF(), but will make spot-checking easy).
MAIN PROCESSING
Let's say your email addresses are in column A, from A2:A1000.
In cell B2, enter this formula:
COUNTIF($A$2:$A$1000,A2)
This will produce the count of each each time the email address in A2 appears in the column. Copy that down column B.
Use Excel's Filter feature to filter your list for those that have exactly 1 in column B.
=IF(COUNTIF($A:$B;A1)=1;A1;"not unique")
If your e-mail addresses are in column 1 and 2, try this formula in column 3

Resources