Creating a new column of values based on another column - excel

I have a list of values with multiple columns. One of the columns contains values under the format "X-Y" (values are not numerical. There are no other hyphens/"-"s in X or Y. The only hyphen is the separator). I would like to create a new column that contains specific values depending on what X is in this one column.
For example, if X = 'egg', I want it to print out 'bacon' in the column next to it. If X = 'duck', I want the value in the column next to it to be 'bird' instead.
If column A held value egg-quack, I would want the column B next to it to print out bacon. If column A held value egg-duck, I would still want column B to contain the value bacon. If column A held value duck-duck, column B would contain the value bird.
I hope this is clear. How would I be able to go about doing this?
I'm not too familiar with data handling in general, so if there are other more effective methods other than VBA, I'm also willing to look into that.
Thank you!

You can use VLOOKUP for this, with FIND to locate the hyphen:

Related

Excel comparison of two columns and print value of other column for the matching entries

I have and excel with the following columns,
aaa,123,bbb
bbb,234,ccc
ddd,456,avc
eee,333,aaa
I need to compare each element in column A with Column C and for the elements existing on column A and C i need to print the corresponding value in b column.For example in above case the output will be like,
aaa,123,bbb,333
bbb,234,ccc,123
ddd,456,avc,not present in C
eee,333,aaa,not present in C
Thanks in Advance,
Raghavan
Use this INDEX/MATCH:
=IFERROR(INDEX(B:B,MATCH(A1,C:C,0)),"not present in C")

Excel: Is there a way to match Two Columns while matching a third

Column B & C's values match each other and Column ID & A's values match each other (as in the codes are the same customer). Column A & B contain the same values but in a different order, is it possible to match those values, allowing all the columns to match?
E.g
---ID---|---A------|------B---|----C---|---D---|
23-------AB12------BA13---------K00
12-------BA13------BC33---------K01
45-------AC31------AB12---------K02
65-------BC33------CC31---------K03
11-------AA22------CB21---------K04
02-------CB21------AC31---------K05
57-------CC31------AA22---------K06
Ideally the first row should be:
| ID | A | B | C | D |
23 AB12 AB12 K02
Can this be done on a large spreadsheet 10,000+ ?
You don't need to change the order of your columns to do that, just use INDEX(MATCH()) instead of vlookup - I'm not quite sure why vlookup is even a thing to be honest.
But first, if you work on a large dataset and maybe you'll have to revisit things later, let's work smartly and NAME OUR RANGES instead of using dirty $A$5 notations.
SO here's our reduced dataset:
Let's select the whole of the columns containing data, like so, and in the upper left corner we're going to name it "col_B" (or whatever else you fancy):
Do that for all the columns you'll use.
You can now set a separate section (or another worksheet completely since you have lots of data) to re-order your dataset. Like so. We're going to use col_A as our reference, so let's already populate it (just copy-past I guess) with your source data:
In our final result, we want column B to be the same as column A. So let's just write that formula in our first cell of column B, and increment that all the way to the end:
You now want col C to be whatever value that correspond to each col B value in your old table - we're going to use Index(MatchT)) like so:
In english this means:
INDEX(COL_TO_RETURN, MATCH(COL_TO_SEARCH_FOR_VALUE, VALUE_TO_SEARCH, 0))
In other words, it will return the corresponding value for col_C (of the source data, so the column you have previously named). It will take the value in D3 (your new sheet's column B) as the thing to search for. It will search for that D3 value inside col_B, the range that you have named so in your source data. "0" just means you want an exact match.
The fact that we named our columns just makes them easier to reference -you could do without but it's a lot cleaner.
Much, much better would be to work with table & structured notation, but that's abit more of a stretch so let's stop it here. The result is this:
Apply the same logic for your ID column & you're done.
If you like the answer, please accept it! (the check mark next to the post)

Excel: match two columns and output third ... AND... there are multiple instances in each column

Working off a previous post:
Excel match two columns and output third
I have values in column A that are not unique and values in column B that are not unique, but together column A and B produce unique combinations:
A B C
1 Red Car Result#1
2 Blue Boat Result #2
3 Red Boat Result #3
4 Green Car Result #4
Let's say I want to find a match where Column A = Red and Column B = Boat which should return the corresponding value in Column C which should be Result #3.
Using the previous post's solution:
=IF(MATCH("Red",A1:A4,0)=MATCH("Boat",B1:B4,0),INDEX(C1:C4,MATCH("Boat",B1:B4,0)),0)
This would actually return value the first match for Boat in column B which would be result#2 rather than the intended result#3 where the match was true.
Any ideas on how to modify or write a function that would specify to retrieve information relative to specifically where the match was true (without using VBA)?
I've thought of a possible work around by creating another column that combines Col A and B to make a unique identifier but I was hoping to avoid that.
Thanks! Really appreciate it and sorry about the table formatting. I'm still very new at this.
You can retrieve a two column match using the AGGREGATE function to force anything that does not match into an error and ignore the errors.
      
The formula in E6 is,
=IFERROR(INDEX(C$1:C$99,AGGREGATE(15,6,ROW($1:$99)/((A$1:A$99="red")*(B$1:B$99="boat")), ROW(1:1))), "")
You are actually using the SMALL sub-function of the AGGREGATE function so you can get the second, third, etc. successive matches by increasing the k paramter. I done this above by using ROW(1:1) which equals 1 but will increase to 2, 3, etc as the formula is filled down.
Creating a third column is the most efficient solution. However if you absolutely have to avoid it, you could use a complicated formula like this:
=INDEX($C$1:$C$6,MATCH(A11,$A$1:$A$6,0) + MATCH(B11,OFFSET($A$1,MATCH(A11,$A$1:$A$6,0)-1,1,COUNTA($A$1:$A$6)-MATCH(A11,$A$1:$A$6,0),1),0)-1)
But the condition is that the lookup table is sorted for both column 1 and 2.

Excel 2010 Count 2 columns when both columns each contain a range of values

I have a large Excel dump from SQL with many columns of data. Two of those columns have different fields with various text values. There are six correct values for the first column and five correct values for the second column. I need to count the accounts (column A) that have both "correct" values.
Well, I just stumbled on this guy:
=COUNTIFS(A:A,"val1",B:B,"val2")
where:
A:A is the first column you have.
"Val1" is the valid value in the first column you want.
B:B is the 2nd column you have.
"Val2" is the valid value in the 2nd column you want.
Unfortunately, that only works if you have 1 value for each column .. and they work more like an AND .. not an OR.
So rather than that, I'd suggest a "helper column":
1) setup your list of valid values somewhere else, and name the lists: "validcol1" and "validcol2"
==IF(OR(ISERROR(MATCH(A2,validcol1,0)),ISERROR(MATCH(B2,validcol2,0))), "", "Valid!")
I solved it through and array that uses "find."
{ =SUM(1*(IFERROR(FIND(b1:b413,"0B,D,E,K,L,S"),0)>0)*(IFERROR(FIND(c1:c413,"0ZA,ZB,ZC,ZF,ZK"),0)>1))}
Note the use of the leading 0 at the start of each set of values.
It's my understanding hard-coding the values into the formula isn't ideal. Anyone have any ideas for that?

using if search formula in excel

is there a way to combine a search formula with a lookup or possibly use an if then statement. I think I have the first part working but need help with the second part. I am looking for values in column A and based on the values found in column A, I need to look at values in other columns and return the value found in that column.
Example, if column A contains value "car", I need to look at column B and return the value found in column B in column F , if column A contain value "boat", I need to look at column C and return the value found in column C in column F.
Any help would be much appreciated
Assuming that you have a list of possible values: car, boat, bike, plane, ... that would lead you to look for values in column B, C, D, E, ... I suggest you do the following:
Define the name "transportation" (whatever name you want to call it) with the types of transportation you need - for example, ={"car", "bike", "tram", "bus", "boat"} . On Office for Mac 2011 you do this with Insert->Name->Define... - for other versions of Excel it might be different (but note - you actually type both the = sign and the {} curly braces around the list of values you want to be able to look up). Put them in the order of the columns that you want.
For every lookup that you need, you can now write
=INDEX(B4:F4,0,MATCH(A4,transportation,0))
if the value (car, bus etc) is in cell A4, and you want to look up the corresponding value from columns B through F.
If you have column headings above your columns, you can use the MATCH function without having to define a name explicitly. For example, if you have car, bike, tram etc in cells B1:F1, you can use
=INDEX(B4:F4, 0, MATCH(A4, $B$1:$F$1, 0))
to do the lookup.
Explanation: the MATCH function (with third parameter 0) looks for the exact match for the first value (in cell A4 in this case) in the array that is the second parameter (either the named range, or the range with fixed address that I gave above). You then look up the appropriate cell using the INDEX function which gives you an offset into the range (B4:B4 in the above) of cells where you need to do the lookup.
I trust you can adapt this to your exact needs. Ask if you need more help.
The following formula is the simplest way I can think to do it:
In cell F1, the formula would be
=IF(A1="car",B1,C1)
This is case insensitive, so it should work for CAR as well. But bear in mind that this has the downside that with a formula this simple, ANY value in A1 other than "car" (not just "boat") would lead to the other value ending up in the F column.
=IF(A1="car",B1,IF(A1="boat",C1,""))

Resources