Searching multiple Postcodes in Excel - excel

I have an excel sheet with 8000 records that i would like to search by postcode.
This is my client list and i would like to say search for all clients living in the "EH1","EH2","KY1","SW9" postcodes.
I would like the search to return all the values related to that postcode.
The excel document is laid out like this.
(ID,Name,Surname,Address,Postcode,Telephone Number)
Im a novice at excel spreadsheets so any help on this would be greatly appreciated.
ID Name Surname Address Postcode Telephone number
26584 John Smith 69 Bedford road Eh12 5db 0131225689
Thanks

Edited with quick and dirty method:
If you only need to use this table a few times, then there is a quick and dirty method:
Make a helper column that only includes the first 3 characters of the postcode. You do this via the left function, specifying the postcode column in the first argument, then "3" in the next, to return the first 3 characters. This effectively hides the values you haven't ticked.
You then use the filter section at the top of the column once you have made it a table as stated earlier. In the drop down menu untick "Select all", then tick the values you want to see, i.e. the postcodes you are interested in).
You can then copy the visible cells only via Copy visible cells only if you want to use just that list.
A longer, but more robust method would involve three tables. The first is your data set as it is, with the helper column as discused above included. The second would be a simple single column of all the first three letter codes you are interested in. The third would be an array function modified from this formula:
=index($a$1:$b$7,small(if($a$1:$a$7=$a$10,ROW($a$1:$a$7)),ROW(1:1)),2)
which returns multiple items based on preset criteria, ignoring those that are not specified. I would link to a site explaining this better but I am such a new user I can hardly do anything it seems :(

I suggest you simply use an autofilter on the respective column.
Here is a short tutorial for Excel 2010: AUTOFILTER TUTORIAL

I think an easy way to do this is first make Postcode column first; from Column E to Column A.
Insert a new column in Column A, then use the left function to get the first 3 characters of the postcode: =LEFT(B1,3)
With this, you can use VLOOKUP to search for the postcodes "EH1","EH2","KY1","SW9", and use multiple VLOOKUP formulas to return a column index of everything.
You'll end up with a list of everything for that specific postcode.

Related

Trying to match two lines of text and return a third in excel

I have a couple of different large lists of equipment on seperate worksheets I am trying to consolidate. The first sheet "List" contains multiple columns of information, including one for the area it will be relocated to. Another sheet, "Locations," contains the three areas where each piece of equipment will be relocated to, seperated in to 3 columns; at the top of each column are the names of the locations 2500, 2900, and Term. The issue is, the Equip# from the "List" sheet only partially matches the names on the "Locations" sheet.
List
Locations
As you can see above, A2203-76 under Equip# only partially matches A2203-76 20% NAP TANK AGITATOR.
This is the formula I am using {=INDEX(Locations!$A$2:$C$2,,MIN(IF(Locations!A3:C151="A2203-76",COLUMN(Locations!A:C),0)))}. This unfortunately will only return the first column value, which is 2500. What should happen is: First, on the List sheet, the New Gear Location cell should check the Equip# cell in the same row, after retrieving the Equip# it should go to the Locations sheet and search for a partial match to what it retrieved from the Equip# cell. After finding a partial match, it should look at the column the match was found in and return one of the 3 cell values from the top "2500, 2900, or Term" based on what column it was found in and fill this value in the cell on the List page that the formula was entered in to.
Another issue, which makes me think this may not be possible, is there are also instances of A2203-75. So I question if excel has the ability to apply I guess "weights" to different partial matches. What I am getting at is, if I applied some function to partially match A2203-76 to something on the other page, would it just stop at A2203 and pick the A2203-75? Or would it look at the whole string first and find the correct instance? Maybe my thinking is wrong, but if you could offer any help I would appreciate it.
Is this what you mean?:
=INDEX(Locations!$A:$B,MATCH(List!$A2&"*",Locations!$C:$C,0),COLUMNS($A:A))
Paste this formula in List!B2 and drag right, down.
It searches for your search text followed by wildcard *.
!! Please note that this will return the first match.
If you are searching for A2203-76 and your data also contains A2203-761 it will return this value if it's found prior to A2203-76 !!

Using VLOOKUP and not only match on first value

I'm trying to use VLOOKUP to match activities with product codes, but run into an issue since VLOOKUP always returns the first match. I did a mockup below to describe my issue. To the left, I have a table with activity names and product codes.
To the right, in column G, I want to, based on matching activity names in column F with activity names in column A, assign the activities product codes from column B.
When I use VLOOKUP, it only matches with the first activity name and give all the activities with the same name the same product codes. I need them to get different product codes even if they have the same name. I want my function to "take the next one" on the list, when the first one is taken.
Should I try to use another function to solve this? Is it impossible with VLOOKUP? My 'real' document has like 2000 rows, and the solutions I found on Youtube was not good to scale.
Thanks in advance. I'm new to here so if I should clarify my question in any way, feel free to tell me.
If the raw is around 2,000 rows, you can use a nested index match with helper columns.
Add a rank in column C with the formula =COUNTIF(A2:$A$2,A2)
Then apply the same ranking in your output part as well (Ensure Activity Name is sorted so that the formula works), Output rank formula =IF(J2=J1,I1+1,1)
Formula that lists out the Product Code {=INDEX($B$2:$B$3190,MATCH(I2,IF($A$2:$A$3190=J2,$C$2:$C$3190),0))}
This is an array formula, you get the curly brackets by hitting control+shift+Enter instead of just Enter upon keying in the formula
If you are using excel 365, you can use UNIQUE formula.
=UNIQUE(A2:B18)

Return array based on titles

I'm, looking for a way to return an array of text based off of titles or headers if you will. My brain isn't working today and I keep struggling to find the best method. I originally was going to have a bunch of IF statements and ran into problems, and I can't seem to figure out if Aggregate is a viable method.
Essentially if "Title 1" is selected from a drop down I would like to return the names within Title 1, and so on. If "All" is selected I would like all to populate from each title. The speed bumps I have is that some names repeat and I only want to show each name once always in alphabetical order. Can someone please get me started on how to tackle this?
In Excel O365 with the FILTER function, you can do this with a helper column (which you can hide, or position elsewhere).
I created a Table and am using structured references, but you can change to ordinary addressing if you prefer.
TitleList is a named range that includes all or your titles (presumeably you will use this for your dropdown).
For the Helper Column, I have it adjacent to your Names column with the formula:
=IF(OR(A2=TitleList),ROW(),B1)
This creates a unique number for each title.
Then, for your formula, under the dropdown, you can use:
=FILTER(Table3[Names],(Table3[Names]<>G1)* (Table3[Index]=XLOOKUP(G1,Table3[Names],Table3[Index])))
where G1 contains the dropdown
With Column B visible:
Some with O365 do not have the FILTER function. If you do not have the FILTER function, you can use:
=INDEX(Table3[Names],AGGREGATE(15,6,1/(INDEX(Table3[Index],MATCH(G1,Table3[Names],0))=Table3[Index])*ROW(Table3)-ROW(Table3[#Headers]),ROW(INDEX($A:$A,2):INDEX($A:$A,COUNTIF(Table3[Index],INDEX(Table3[Index],MATCH(G1,Table3[Names],0)))))))
EDIT
To return a non-duplicate list of ALL of the names, add ALL to TitleList and use this formula instead.
This formula makes a special case for ALL and filters out the rows that contain a Title
=IF(G1="ALL",UNIQUE(FILTER(Table3[Names],COUNTIF(TitleList,Table3[Names])=0)),FILTER(Table3[Names],(Table3[Names]<>G1)*(Table3[Index]=XLOOKUP(G1,Table3[Names],Table3[Index]))))
.imgur.com/apkHh.png

Trying to remove bad data using countif function

First, thank you for the help in solving this problem. It's pretty simple but I'm just not getting it.
In excel, I have 2 tabs. In the first tab, I have rows of personel data (job title, country of business, Industry, etc.)
In the second tab, I have a column of prohibited titles. These are titles that don't match the criteria we want.
I'd like to create a formula that checks the rows in tab 1 against the prohibited titles in tab 2. If the data matches, I'd like it to return 'N' in column A, which signals that we should remove that row of data. Title information is found in row F on tab 1.
My various countif functions aren't working and I'm not sure why.
Various countif formulas, like
=COUNTIF(F:F,"'Bad Titles!'A:A")
Produces N for all titles we want to disregard
Use MATCH it is quicker:
=IF(ISNUMBER(MATCH(F2,'Bad Titles!'A:A,0)),"N","")
If the matches are partial then:
=IF(SUMPRODUCT(--ISNUMBER(SEARCH('Bad Titles!'$A$1:$A$100,F2))),"N","")

Excel Average Questions

So I have to excel sheets. Each sheet looks like this:
Name Value
Bob 1234
Sally 2343
Joe 564564
Essentially I have 300 names and their values. I have a second sheet that has the same names but with different values. I would like to know the easiest way to get the average value for everyone's name across the multiple sheets. I only have two sheets now, but I would like to be able to do it for more in the future.
If the position is the same in all sheets, this is fairly simple:
=AVERAGE( Sheet1!A1, Sheet2!A1, Sheet3!A1 )
or
=AVERAGE( Sheet1:Sheet3!A1 )
However, if the position varies, you'll have to make use of the formulas in the lookup category.
Is Bob on the same row in each sheet? Are there sheets where there is no Bob? Would bob show up multiple times?
Either way, this is something that would probably be more suitable to storing in a database. Excel can still grab things from the DB and display as a spreasheet, but doing average as you want will be far far far easier in a DB.
However, if Excel it has to be, then you'd need to use search functions to find Bob in each worksheet, then get his associated value. =LOOKUP() would probably help for the searching/lookup parts, but you'd still need to do this for every worksheet.
Lets say you have 3 sheets with the same names, in the same position. Insert a 4th sheet where you copy those names. In the results column, type =AVERAGE(Sheet1:Sheet3!A2), and copy that formula down.
Done.
If you plan to add more sheets later, keep a Special sheet that will always remain empty, and make your formula: =AVERAGE(Sheet1:Special!A2).
You will then be able to insert the new sheets BEFORE Special, and your average will need to be edited.
Use an array formula. Enter the following into the first cell replacing 'Bob' with the cell reference for the 'Bob' entry, and hit CTRL+SHIFT+ENTER:
= SUM((name_col2='Bob')*(value_col2))/sum((name_col2='Bob')*1)
There is no easy way in Excel. You have to write VBA code. You need to define all your sheets you need for your calculations go through all the names and put them in an array.
// [Name, Number, Count of Sheets]
[["Bob", 1234, 1], ["Sally", 2343, 1], ...]
For every name in every sheet you need to check if it is included in your array.
If this is the case increase the number and the count otherwise add a new element with [Name, Number, 1]
At the end go through your array and output Name and Number / Count to a new sheet.
You need some basic programming skills.

Resources