Can I have an excel formula post output multiple results? - excel-formula

I have an interesting question. I am close with my current formula but am not sure if there is a better way to do this.
I have data from a PDF that I am importing into excel and it is pretty messy. It is a large compilation of different filings that include the name, address, county, etc.
When exported to excel the cells are merged in odd ways that make it hard to reference other cells.
Essentially I am wondering if there is a way for my formula to output the name, address, and county, each time it finds "Debtor Name" on the spreadsheet.
You can't tell from the photo but the cells are all merged and it makes referencing them difficult.
My current formula is =IF(ISNUMBER(SEARCH($Z$1,A7)),A8," ")
$Z$1 = "Debtor Name"
A7 = "Debtor Name" (From the cell information)
A8 = "name"
If true it outputs the "name" into my table I am creating. This is where it would be perfect to output the Debtor Type, Address, and County!
If false I output a space (so I can run this formula all the way down the 400 cells where Debtor Name appears in the A column. I later then turn the spaces into blanks, and remove them.
Any help would be appreciated and I will provide more information if needed.

Use & to add multiple cell values to your output.
=IF(ISNUMBER(SEARCH($Z$1,A7)),A8&B8," ")
# or
=IF(ISNUMBER(SEARCH($Z$1,A7)),A8&" "&B8," ")
First example just concatenates the values from cells A8 and B8.
Second example adds some text between the cell values. In this case I specified a space, but you could use a comma, underscore, entire phrases, etc.

Related

How to categorise a column in excel based on another column that contains value in string separated by semicolons

I have the following spreadsheet on the image (please click on link below for image):
Raw data and categorised data
Suppose I have the raw data Name B4:B11 and Interests C4:C11.
My question is I want to categorise the raw data so the output is as pictured in B16:B34 and C16:C34. I am trying to categorise people by their interests when their interests are in a column containing strings separated by semicolon. The Name can come up multiple times according to their interests where in this case Movie, Music and Radio.
Please kindly assist. Thanks kindly.
This formula will work as in the picture below.
This will need to be entered as an array formula (when in the formula bar hit Ctrl+Shift+Enter)
=IFERROR(INDEX($B$1:$B$11,SMALL(IF(ISNUMBER(SEARCH(B$15,$C$1:$C$11)),ROW($C$1:$C$11)-ROW(INDEX($C$1:$C$11,1,1))+1),ROW(1:1))),"")
Array formula's break down ranges and calculate them them one cell (or row) at a time.
The SMALL formula (=SMALL(array,k)) will use the array results of the IF formula. The IF formula is returning either FALSE (default) or the row number when the text can be found in the cell using search, I have used =ISNUMBER to force true false rather than it throwing any errors as if it finds the text it will give a numeric value as the starting position of that string in that cell.
The SMALL formula puts the results in the array in ascending order and will only call on actual values (not FALSE) so I have used ROW(1:1) at the end of the small formula for the k part: When the row automatically increases to the next number, the next highest result is displayed.
I hope this helps explain the logic used.

Can Not Get My VLookUp In Excel To Return The Requested Data

Can Not Get My VLookUp In Excel To Return The Requested Data
I am trying to pull data from another sheet based on data selected from a dropdown on the main sheet.
All the formatting is "General"
=VLOOKUP(F15737,'Location Master'!$A:$J,2,FALSE)
It just keeps returning me #N/A
Try using the Index Match method. It's an alternative to Vlookup which doesn't require data to be sorted and can therefore be of more use.
The typical structure of this method is (the text inside the asterisk will give the ranges specific to your sheet:
=INDEX (**Column from which you want to return a value**, (MATCH(**Lookup Value**, **Column against which you want to lookup**,0))
In this case, if I've understood your workbook structure, the formula should look like this:
=INDEX('Location Master'!$B:$B,(MATCH(F15737,'Location Master'!$A:$A,0)))
This is a common problem with VLOOKUP(). Most likely you have some whitespace (A tab character or some spaces) after one of the values. Click on F15737 and see if there are any spaces at the end of it. Likewise, manually find the value in 'Location Master'!$A and check it for spaces or tabs after the value.
If the whitespace is found in F15737 then you can change your vlookup to be:
=VLOOKUP(TRIM(F15737),'Location Master'!$A:$J,2,FALSE)
If the whitespace is in the range to which you are looking up, then you'll need to trim all of those values, which you can do pretty quickly in a new column with the TRIM() formula.
If this doesn't solve the problem then you might have a number stored as text. Generally excel will tell you if this is the case within the cell with a little green corner indicator. To get Excel to automagically change a column from a "Number stored as Text" to a proper number you can:
Highlight the column
Go to Data>>Text To Columns
Click "Fixed Width"
Click "Finished"
Excel will then format everything automatically (dates to dates, numbers to numbers, text to text, time to time, etc.)

How to apply conditional formatting in excel for multiple text conditions

I am trying to delete a large number of cases (Tweets) in excel based on certain words. Only one word has to be present for me to delete it.
example:
blue big bird
orange bird flies
elephant is angry
cool cat in tree
List of words I would want to delete on: bird, blue and cat. Therefore, the function should delete 1. 2. and 4, no matter if all words are present, or only one or two. Currently I only know how to format it based on one word, but I have roughly 50 words per file to filter on, so it would save a lot of time to have a function. I am not sure which function works for this? I already have a list of the words I want to delete on in another spreadsheet.
The formula you are searching is
=IF(SUM(COUNTIF(B2,"*"&{"cool","orange"}&"*"))>0,B2,"")
where B2 is a cell in the row with your values (e.g. 1. blue big bird).
Apply this for every cell and you get the cell value for every hit and "" for no hit.
If you already have a list of words in a spreadsheet, you can assign that list a range name, since 50 words are a bit much for a formula and hard to maintain.
Consider the following screenshot. The highlighted range has the range name TriggerWords.
The formula in cell B1 is
=IF(SUM(COUNTIF(A1,"*"&TriggerWords&"*"))>0,"",A1)
which is an array formula that must be confirmed with Ctrl-Shift-Enter. Then copy down.

I need help consolidating a list of supplier names that change periodically?

I have a spreadsheet that I am using as a questionnaire.
One of the questions is Who are your wheel suppliers (mark all that apply)? and there are 6 check boxes in column C to select 5 different wheel suppliers and an Other option. I have these check boxes linked to return whatever suppliers name is selected in the cell adjacent to the cell the check box is in in column I.
So depending on what wheel suppliers the customer selects there could be anywhere from 1-6 different suppliers selected. So once the customer has selected the wheel suppliers whatever suppliers are selected will show up in the correct cell in range I45:50.
What I am having a problem with is that I need these to pull into a data tab into one cell. I am having a problem coming up with a formula to put all the suppliers together as a list in one cell with commas separating each. Remember, it could be 1 supplier, could be 3, could be 6.
Any advice is much appreciated. I have tried using If formulas and Concatenate but I can't seem to figure out how to get it to work like I want it to.
=CONCATENATE(Questionnaire!I45," ",Questionnaire!I46," ",Questionnaire!I47," ",Questionnaire!I48," ",Questionnaire!I49," ",Questionnaire!I50)
That is the best I've come up with but the problem with it is if the first supplier isn't selected then it will enter that space anyways and if the first supplier and the last supplier are selected it will have all those spaces in between.
Another method, this one using helper cells.
Say you have the data in A1:A6. In B1, input this formula: =IF(LEN(A1)>0,A1&",",""). Drag down to B5.
In B6, slight variation: =IF(LEN(A6)>0,A6,",""").
In C1: =CONCATENATE(B1,B2,B3,B4,B5,B6).
What happens is the cells in the B column checks if their respective values in the A column are not blanks. If not, they will append , to it. Otherwise, they will return blanks (not spaces). The only variation is B6--since it's the end of the list, there's no , appended to it.
It's only a matter of concatenating them at this point. Removing any of the values in A, maybe by unchecking their checkbox, will reflect the change in C1 properly.
Let us know if this helps.
EDIT:
To accommodate your formula, change your CONCATENATE formula to something like below:
=LEFT(CONCATENATE(...),LEN(CONCATENATE(...)-1)
What is does is it removes the rightmost character by getting, from the left, all the characters up until one less than the length of the result. Obviously, fill in the ... with the ranges you want to concatenate.
Let us know if this is what you need.
FURTHER EDIT:
=LEFT(CONCATENATE(Questionnaire!F45,Questionnaire!F46,Questionnaire!F47,Questionnaire‌​!F48,Questionnaire!F49,Questionnaire!F50),LEN(CONCATENATE(Questionnaire!F45,Questionnaire!F46,Questionnaire!F47,Questionnaire‌​!F48,Questionnaire!F49,Questionnaire!F50))-1)
Looks ugly, right? But does the job. Better if you use a named range, though, like below:
Now it's much shorter. Error on my end is because I don't have Questionnaire sheet, obviously.
If J44 is blank and you are prepared to add something like =IF(ISBLANK(I45),J44,J44&I45&", ") in J45 (copied down) then perhaps:
=SUBSTITUTE(LEFT(wheelC,LEN(wheelC)-2),0,"")
might suit, where wheelC is a named range of workbook scope for Questionnaire!J50.

Is it possible to do a LEFT or RIGHT function in conjunction with a LEN on a randomly populated cell of varying length?

Preamble: I have a problem and I've got a very simple solution that I'm using. However, I was wondering, for the sake of learning, if any Excel Guru's out there had an alternate solution to my problem.
I have an excel table with a column that contains about 4500 U.S. and Canadian cities.
Here’s a sample of the way the data in the column is formatted:
Toronto, ON
Jacksonville, FL
VANCOUVER, BC
On another sheet in the workbook, I randomly select a City.
So I’m using the following function:
=INDEX(DATA!$E$2:$E$4576,RANDBETWEEN(1,4574),1)
This function produces a random selection from the 4500 cities; the problem is that I want to populate two cells, one that has the City and one that has the Province/State.
Typically, extracting the City/Province from a cell formatted ‘City, Province’ is pretty straight forward.
I’d do something like this:
For the State or Province:
=RIGHT(A1,2)
For the City:
=LEFT(A1,LEN(A1)-4)
My problem lies in the random selection of the city/state.
I can’t select the city using:
=LEFT(INDEX(DATA!$E$2:$E$4576,RANDBETWEEN(1,4574),1),LEN(INDEX(DATA!$E$2:$E$4576,RANDBETWEEN(1,4574),1))-4)
Because when I’m calculating the LEN function, it randomly selects another city and uses that length for the calculation. So depending on the combination of random city selections in the one function, some will be short, some will be long (and some will be accurate).
An extension of the same problem is when I do the RIGHT string function to get the state, that'll be from another randomly selected value, so it won't (necessarily) match the city.
The simplest thing I could think of, and it's what I've done, is to make the random selection in one cell, then perform the RIGHT and LEFT functions on that cell.
Like this:
//populate cell A1 randomly
A1=INDEX(DATA!$E$2:$E$4576,RANDBETWEEN(1,4574),1)
//pull the province/state form A1
B1=RIGHT(A1,2)
//pull the city name from cell A1
C1=LEFT(A1,LEN(A1)-4)
I'm just curios if there's another way of doing the LEFT/LEN function on the RANDOM selection without having to play off of another cell. I'd like to avoid VBA if possible. It's possible there isn't a solution, but I'm hoping someone who knows more than I do will have some ideas!
Try this formula to get a random city without the province
=TRIM(LEFT(SUBSTITUTE(INDEX(DATA!$E$2:$E$4576,RANDBETWEEN(1,4575)),",",REPT(" ",99)),99))
Note: you have 4575 rows of data so you need the RANDBETWEEN to go up to 4575 otherwise you aren't considering the last row
That formula replaces the comma with 99 spaces then takes the first 99 characters and trims off the spaces - that is one way to get the City only without having to use RANDBETWEEN again.
Now assuming your cities are all different you can use VLOOKUP to lookup that City with a wildcard and get the province, e.g. with the above formula in A2 use this formula in B2
=RIGHT(VLOOKUP(A2&",*",DATA!$E$2:$E$4576,1,0),2)
If cities might have duplicates then you can use this "array formula" in B2 instead
=RIGHT(INDEX(DATA!$E:$E,SMALL(IF(LEFT(DATA!$E$2:$E$4576,LEN(A2)+1)=A2&",",ROW(DATA!$E$2:$E$4576)),RANDBETWEEN(1,COUNTIF(DATA!$E$2:$E$4576,A2&",*")))),2)
confirmed with CTRL+SHIFT+ENTER CTRL+SHIFT+ENTER
You can't guarantee that the province returned by the second formula was the same as the one from the cell chosen in the first formula (unless the city has no duplicate) but that won't matter. If there are duplicate cities it will pick one of the provinces at random
It is not possible, because the formula RANDBETWEEN () is calculated independently in each cell.
Thus, to get the same random value, proceed as already doing.

Resources