assigning name on a specific character in a cell - excel-formula

i want to assign a name on a specific character in a cell
ex. Cell A1 is 123456HL78
i want to name the 5th character in cell B1 as:
if 5 "Branch"
if 6 "HO"
if 7 "franchise"
and the 6th character in cell C1 as:
if 6 "City"
if 7 "Province"
if 8 "Others"
therefore, result in B1=Branch and C1=City
thanks

You can do this with a lookup table and use INDEX and MATCH or VLOOKUP if you prefer along with the MID function to return the 5th or 6th character from a text string and return a specific value based on that character.
In A1 123456HL78
In B1 =INDEX($E$1:$E$2,MATCH(MID($A$1,5,1),$D$1:$D$2))
In C1 =VLOOKUP(MID($A$1,6,1),$D$1:$E$4,2)
In D1 ="5" 'The = and quotes are important, without them Match and Vlookup cannot find a match and return a #value error.
In D2 ="6"
In E1 Branch
In E2 Province
You can obviously expand this however you like. Just note the hard coded 5 in the B1 MID function because you want the 5th character, as well as the 6 in C1.
Hope this helps.

Two nested if formulas will work.
In A1 123456HL78
In B1 =IF(MID(A1,5,1) = "5","Branch",IF(MID(A1,5,1) = "6","HO",IF(MID(A1,5,1) = "7","Franchise","")))
In C1 =IF(MID(A1,6,1) = "6","City",IF(MID(A1,6,1) = "7","Province",IF(MID(A1,6,1) = "8","Others","")))

Related

Complex excel problem, parse string then get max date from cell next to matching cell

Below I have one or more strings in cells D7 D8 and D9 separated by a comma. I would like to get the max date corresponding to the numbers provided.
--- Col A Col B
Row 1 number date
Row 2 1.0 1/1/2018
Row 3 1.1 1/2/2018
Row 4 1.3 1/5/2018
Row 5 1.6 1/3/2018
Row 6 1.8 1/4/2018
text string in cell D7 = 1.1,1.6
output = 1/3/2018
text string in cell D8 = 1.1
output = 1/2/2018
text string in cell D9 = 1.8,1.6,1.3
output = 1/5/2018
Use this array formula:
=MAX(INDEX(B:B,N(IF({1},MATCH(--TRIM(MID(SUBSTITUTE(D2,",",REPT(" ",99)),(ROW($A$1:INDEX($A:$A,LEN(D2)-LEN(SUBSTITUTE(D2,",",""))+1))-1)*99+1,99)),A:A,0)))))
Being an array formula one must first put the formula in the First cell then hit Ctrl-Shift-Enter instead of Enter when exiting edit mode, then copy down the dataset.
Another using SUMIFS:
=MAX(SUMIFS(B:B,A:A,TRIM(MID(SUBSTITUTE(D2,",",REPT(" ",99)),(ROW($A$1:INDEX($A:$A,LEN(D2)-LEN(SUBSTITUTE(D2,",",""))+1))-1)*99+1,99))))
Still an array formula

Dragging formulas across - Increment columns by more than 1

I can't seem to find anything similar that's already been asked (they all relate to incrementing row numbers rather than columns)
I'm looking to drag a formula across horizontally and have the columns increment by 2
E.g. B1-A1, D1-C1, F1-E1...
Thanks!
You'll need to have a value in cell A1 and B1 for the following to work.
For my testing I put the number 1 in A1 and B1.
Try this in Cell C1:
=IF(MOD(COUNT($A$1:B1),2)=0,COLUMN(B1),IF(B1<>A1,B1,A1))
Here's what you should see when you drag that formula across:
A B C D E F G H I J K L M N
1 1 2 2 4 4 6 6 8 8 10 10 12 12
And this is what the formula does:
The MOD(COUNT() part of the formula counts the cells to the left of it, and if they are a multiple of 2, the value changes.
I've left the value to change to (the 'new' value) as the COLUMN() number for the cell before, just for example's sake. but you can change this part.
The last IF statement at the end checks if the cell before is equal to the cell before that, (eg. Is CELL C1 equal to CELL B1) and if they are not equal, it will give the cell before as a value (the 'copy' value).

Excel. Convert text to values and calculate the values in a formula

I want to convert text to values and then with this values calculate a result:
Text "A" is always = 8
Text "B" is always =7
In my sheet:
In cell A1:"A" and in B1: "B". Now in cell C1 I want the sum of A1 and B1 (8+7=15).
I always want the cells A1 och B1 to show text not values.
And if it possible I dont want any intermediate cells that convert A1 to 8 and B1 to 7 so the resultformula points at that intermdediate cells. I want my result (C1) to calculate the text cells directly. Is this possible?
=IF(A1="A",8,IF(A1="B",7,NA()))*IF(B1="A",8,IF(B1="B",7,NA()))
It is easier to have a separate translation list, say on Sheet2 cells A1:B6:
A 8
B 7
C 6
D 5
E 4
F 3
and then use:
=VLOOKUP(A1,Sheet2!$A$1:$B$6,2,FALSE)*VLOOKUP(B1,Sheet2!$A$1:$B$6,2,FALSE)

Excel formulas on triming a cell value

I want to trim a row in excel which contains the following values:
row a row b
texas/dallas 5
texas/austin 10
california/sf 5
california/la 20
to
row a row b
texas 5
texas 10
california 5
california 20
It sounds like what you want to do is get the value of everything to the left of the / symbol in a particular field. To do that, you can use the following formula:
=LEFT(A1,FIND("/",A1)-1)
where A1 is the cell you want to change.
Here's how it works:
Find("/", A1) finds the first instance of the "/" in the text in A1 and returns it's position.
Then Left(A1, <#>) takes all the characters to the left of position calculated by the previous expression.

Change value in a cell based on value in another cell

Searched for this but could not find a way to do it.
I would like to be able to transform a value in one cell to another value in a different cell like this:
When cells in Column A contain Y set same number cells in Column B to Male or when cells in Column A contains N set same number cells in Column B value to Female.
For instance:
A2 = Y then B2 = Male
A2 = N then B2 = Female
=IF(A2="Y","Male",IF(A2="N","Female",""))
by typing yes it wont charge taxes, by typing no it will charge taxes.
=IF(C39="Yes","0",IF(C39="no",PRODUCT(G36*0.0825)))
If you want to do something like the following example, you'd have to use nested ifs.
If percentage is greater than or equal to 93%, then corresponding value in B should be 4 and if the percentage is greater than or equal to 90% and less than 92%, then corresponding value in B to be 3.7, etc.
Here's how you'd do it:
=IF(A2>=93%, 4, IF(A2>=90%, 3.7,IF(A2>=87%,3.3,0)))

Resources