Remove specific character from a cell depending on the cell value - excel-formula

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
Appreciate your answer!

Something like this should do it:
=IF(TEXT(B1,"0") = LEFT(TEXT(A1,"0"), LEN(B1)),A1,CONCATENATE(B1,A1))
The logic is fairly straight-forward - take as many characters as the length of your country-code from the full number, and see if they equal the country code. If they do, ignore the country code, and just display the number; otherwise concatenate the two values.
Not sure why 'text' is needed, but fair enough I guess.

Related

Displaying a label, sorted in a third column pulled from the first column according to data in the second column? i.e. Ranking

Imagine you have spreadsheet with data in a fixed # of contiguous rows.. let's say row 1 through row 20
Now let's say you have 3 columns of interest.
A, B and C
Column A is a label column.. the data in there are just string labels.. let's say types of canned food.. Tuna, Spam, Sardines, etc.
Column B is our number column.. let's say it is prices. e.g. 2 for Tuna, 5 for Spam and 3 for Sardines. These prices can change often very rapidly.. ok so prices are not the best example but let's imagine that prices change rapidly.
Now Column C is where we want to put the formula.
I would like to have a formula in Column C that will pull the labels from Column A, based on their prices in column B and rank them from highest to lowest.. that is C1 would calculate to "Spam", C2 to "Sardines" and C3 to "Tuna"
right now there are 20 rows of data.. but maybe at some other point there might be 30 or 6 or 40, etc.
So can someone help me out with the formula or at least explain what functions I need to use and the general idea involved? thanks
=IF(A2:A200<>"";SORTBY(A2:A200;B2:B200;-1);"")
You can simply use SORT formula. In this case =SORT(A1:B1000,2,-1) where A1:B1000 is range to be sorted, second parameter 2 is column number from range to sort by, 3rd parameter for order (-1 is desceding).
Place formula in C1 and you will get spilled array.

Excel: Finding next equal match in column

I've googled for a solution to my problem for days and I just can't seem to get my head around how to do this.
I have 28 chickens and I track the eggs each one lays each month. My Excel sheet looks like this:
Current Egg-cel sheet
Column C is populated by the formula:
=LARGE($A$2:$A$29,$B1)
I'm using column B to increment the LARGE function
I want column D to populate with which chicken number laid the quantity in column C.
Obviously INDEX MATCH or VLOOKUP returns the first match for all equal values. How do I find the the next match? i.e.
Egg-cell sheet 2
I've seen similar questions and solutions but I for the life of me can not get it to work.
Use this formula in D2:
=INDEX(B:B,AGGREGATE(15,6,ROW($A$2:$A$29)/($A$2:$A$29=C2),COUNTIF($C$2:C2,C2)))
And drag down
If you're happy to add a few helper columns, this is a simple way to go:
The formula in column C creates a unique number by bringing together the eggs laid and the chicken number
=--(A2&"."&B2)
Column D is just your LARGE formula,
=LARGE($C$2:$C$4,B2)
Column E just gets the integer part of column D
=INT(D2)
And finally Column F gets the decimal part (chicken number) from column D
=--REPLACE(MOD(D2,1),1,2,"")

=COUNTIF using exclusion?

The scenario is I have "B" and "W" generated randomly in column B and column C. I used "=countif(B2:B286, "W") to count how many "W"'s there are in Column B. I need to do the same in column C, but I need to make sure that I do NOT count the "W"'s in column C that have B's next to them in column "B". Any help is much appreciated.
Use this:
=COUNTIF(C:C,"W") - COUNTIFS(B:B,"W",C:C,"W")

Formula to return the maximum value from 3 columns, but only include a column if the column if the heading appears in a text in another cell

I'm looking for a bit of help with a formula to return a Maximum value from a number of columns(BSS, HPRSS, PBSS), but only if the column heading appears in the column what to calculate!
If it doesn't then it needs to be excluded from the return.
Being honest I don't know where to begin, and I've searched for similiar solutions but can't find anything useful.
My Dataset is laid out as below
A B C D E
BSS HPRSS PBSS What to Calculate
$50 $100 $500 BSS or HPRSS
The formula would be in E to return the max of the headings that appear in D
which in this case is the greater of BSS and HPRSS ($100)
Any help would be appreciated.
Thanks
Use this formula:
=MAX(IF(ISNUMBER(SEARCH(A1:C1,$D$2)),A2:C2))
and press CTRL+SHIFT+ENTER to evaluate it.

Column A numbers matched with Column B numbers that are assigned to Column C =column D?

This is my example
Column A are numbers
Column B are numbers
Column C are Names
The A column are numbers associated with a item sold to one place. Column B is the items sold and C is the person who sold them. I would like column D to show the item sold to this one place and who sold it. Let me know if that makes sense.
PS: Column A has 1304 rows. Column B and C have 6154 rows
It is hard to guess what your data looks like, so assuming your data looks as below:
Here is my solution, I think it is a simple VLOOKUP problem:
Paste this =IF(ISERROR(VLOOKUP(C2,$A$2:$A$4,1,FALSE)),"","SoldToPlaceA") to E2 and drag it down to copy.

Resources