I want to simplify an everyday work task. I am looking for a macro or a formula that will look at Column C, and if New is present, combine N with the data from Column A; if Used is present, combine U with the data from Column A.
Before:
A B c
123456 New
234657 Used
345678 New
After:
A B c
123456 N123456 New
234657 U234567 Used
345678 N345678 New
In the case where its not a matter of IF in column C but just whatever the first letter of column C is, drop the IF portion and go straight to the concatenation.
=LEFT(C1)&A1
Assuming there are only New and Used, this can go in B1 and drag down.
=IF(C1="New","N"&A1,"U"&A1)
If there are other options, then you can use this one:
=IF(C1="New","N"&A1,IF(C1="Used","U"&A1,""),"")
Alternate:
=IF(OR(C1={"New","Used"}),LEFT(C1)&A1,"")
Related
Can someone help on this? I have column A with telephone number and Column B with country code. I want to remove the country code in column A if it is there to avoid duplication. Can someone help me?
Column A 1234567 Column B 1 Column C 1234567
Column C should have the formula to check if 1 is already in the beginning of the cell value A, if yes, it'll remove it, but if not, column B value will be added to it. Another scenario is below: Column A 234567 Column B 1 Column C 1234567
Also, I would like to add separators in this formula after the country code, and after three digits of the country code based on column 1 with removed country code in it.
How to append it in this formula?
=IF(B1 = --LEFT(A1, LEN(B1)),A1,--(B1&A1))
Appreciate your answer!
As far as I understand what you describe, you may be after something like this:
="+"&TEXT(B1,"0")&"-"&
IF(LEFT(TEXT(A1,"0"),LEN(TEXT(B1,"0")))=TEXT(B1,"0"),
MID(TEXT(A1,"0"),LEN(TEXT(B1,"0"))+1,99),
A1)
The statement about "after three digits of the country code based on column 1 " is unclear. This formula gives you tools to add characters before and after the country code, while it removes country code duplication.
edit after comments You don't really describe it, at least not clearly, but it looks like you want a vertical bar after the country code and again after the first three digits of the phone number. The formula to achieve that is
=TEXT(B1,"0")&"|"&
REPLACE(IF(LEFT(TEXT(A1,"0"),LEN(TEXT(B1,"0")))=TEXT(B1,"0"),
MID(TEXT(A1,"0"),LEN(TEXT(B1,"0"))+1,99),
A1),4,1,"|")
another edit after stitching together what else you might want but don't clearly describe: If column B can possibly contain either numbers like 1 or 63 but also text that starts with a country code, followed by a space and some other stuff, like 63 2, then you can use this formula
=LEFT(TEXT(B2,"0"),FIND(" ",TEXT(B2,"0")&" ")-1)&"|"&
REPLACE(IF(LEFT(TEXT(A2,"0"),LEN(TEXT(B2,"0")))=TEXT(B2,"0"),
MID(TEXT(A2,"0"),LEN(TEXT(B2,"0"))+1,99),
A2),4,1,"|")
hope you can help me :-)
My table looks like this:
A B C D
23940823 Larissa Horst =VLOOKUP(C1;A1:B2000;1;FALSE)
23940824 Horst Leon =VLOOKUP(C2;A1:B2000;1;FALSE)
23940825 Fred Kim =VLOOKUP(C3;A1:B2000;1;FALSE)
23940826 Horst Peter =VLOOKUP(C4;A1:B2000;1;FALSE)
I would like to get the number from the specific A, if the Value of C is in B. So for "Horst" it should be "23940824"in this case, but it only displays "#NV".. Do you know why?
It's because SVERWEIS search the first column and goes to right. You need here INDEX instead:
=INDEX(A:A;C1) 'where C1 is your search string
See also MS-docu: https://support.office.com/de-de/article/INDEX-Funktion-a5dcf0dd-996d-40a4-a822-b56b061328bd
Update
First check if the value of cell C is in column B. If so it displays the value of cell A he is finding:
=IF(ISERROR(MATCH(C1;B:B;0));"Not in Column B";INDEX(A:A;MATCH(C1;C:C;0))) 'for D1
Remember that the key words could be different if you use no english excel version (like english = IF, german = WENN)
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.
Say I have A, B, C, D, ...X, Y, Z in Column A. And I have numbers in column B as 10,20,30,40,50...for the corresponding A cells. I want to sum values of B where A is a vowel. How do I do it? I tried the 2 options below but that doesn't work
=SUM(FILTER(B1:B26,((A1:A26="a") OR (A1:A26="e")OR (A1:A26="i") OR (A1:A26="o") OR (A1:A26="u"))))
Also
=SUMIF(A1:A26,"a"|"e"|"i"|"o"|"u",B1:B26)
For what they are worth, 'clarifications' from OP's comments
If the column had values like "Sunday", "Monday" .. and then we had to sum values corresponding to Weekdays.
If I had values like abc, deb, bcd, cde then it may fail when I want summation for bcd
Seems to work both in Excel and in New Google Sheets:
=SUMPRODUCT(SUMIF(A1:A26,{"a","e","I","o","u"},B1:B26))
this works for me:
=ARRAYFORMULA(SUM((ISNUMBER(FIND(A1:A26,"aAeEiIoOuU")))*(B1:B26)))
for general case (when column A contains some word), use this one:
=ARRAYFORMULA(SUM((ISNUMBER(FIND("|" & A1:A26 & "|";"|a|A|e|E|i|I|o|O|u|U|")))*(B1:B26)))
change "|a|A|e|E|i|I|o|O|u|U|" to fit your requirements, e.g. "|Sunday|Monday|"
I have a large table in excel that has column headings A, B, C, D, and ANSWER
A, B, C, D represent the multiple choice questions I have in the table.
I also have an ANSWER column that has the answers represented by the corresponding multiple choice heading letter mentioned above.
For example, under each column heading (A, B, C, D), I have the possible answers, Food, Car, House, School.
In the example above, House (C) is the correct answer. I would like to create an IF statement that matches the Answer cell, which has C in it with the A, B, C, D column headings and if there's a match, then insert an = before the actual answer. In this case, the result would be =house. The rest of the answers should have the ~ inserted before the word, i.e., ~food, ~car, ~school.
The final result should look like this: ~food, ~car, =house, ~school.
The only way to achieve that securely is to duplicate the table in another sheet or in different columns.
Why is that?
Because you want to change the SOURCE of your statement. Excel would consider that a circular reference and couldn't resolve it.
There's a VBA code solution, that you can run ONLY ONCE. That would change the source data as well and you would lose your originals. Could be an action with no turning back.
So:
I suggest you create a new sheet, put the headers A, B, C and D.
So you would have two sheets: the OriginalSheet containing the answers and each option.
And the ResultSheet, containing the options formated as you want.
In the ResultSheet, use this formula:
= IF(OriginalSheet!$E2 = A$1; "="; "~") & OriginalSheet!A2
That is considering the first line containig the texts: A, B, C and D. So you must insert this formula in the A2 cell of the ResultSheet.
You can click in the little black square in bottom right of the cell and drag this formula to all other cells. (The $ simbols garantee the drag will be safe)