Replace last number using provided matrix

richmcgill

Board Regular
Joined
Feb 4, 2019
Messages
83
Office Version
  1. 2016
Platform
  1. Windows
I need to apply the matrix below to a group of numbers
The matrix replaces the last number of the whole number with the specified character.
A negative number
-2505.25 would be 2505.2N
A positive number
31066.83 would be 31066.8C

Make sense?

Final Digit of NumberPositive Replacement CharacterNegative Replacement Character
1AJ
2BK
3CL
4DM
5EN
6FO
7GP
8HQ
9IR
0{}
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
What does your data look like? And are you looking for a formula option or VBA?
 
Upvote 0
What does your data look like? And are you looking for a formula option or VBA?
Looking for a formula.
Loan number
What does your data look like? And are you looking for a formula option or VBA?
Loan NumberCodeReasonDateBalanceCoulmn E should be
1234565AAAA001-25789.5625789.5O
2345676BBBB00255789.4555789.4E
3456788CCCC008-8886.788886.7Q
4567897EEEE00545879.5245879.5B
 
Upvote 0
Give this a try:
Book1
ABCDEFG
1Loan NumberCodeReasonDateBalanceCoulmn E should beFormula
21234565AAAA1-25789.5625789.5O25789.56O
32345676BBBB255789.4555789.4E55789.4E
43456788CCCC8-8886.788886.7Q8886.78Q
54567897EEEE545879.5245879.5B45879.5B
Sheet1
Cell Formulas
RangeFormula
G2:G5G2=LEFT(ABS(E2),LEN(E2)-1)&LOOKUP(RIGHT(E2,1)*1,Sheet2!$A$2:$A$11,IF(E2>=0,Sheet2!$B$2:$B$11,Sheet2!$C$2:$C$11))


Book1
ABC
1Final Digit of NumberPositive Replacement CharacterNegative Replacement Character
21AJ
32BK
43CL
54DM
65EN
76FO
87GP
98HQ
109IR
110{}
Sheet2


And just a note, because of your comment in col F, a formula cannot change the value in a cell. So, if you are wanting the results to show in col E where the balance is already, you will need to use VBA. A formula will need to be in its own column.
 
Upvote 0
Another option (changing the order of the character table):

Book1
ABCDEFGHIJK
1Loan NumberCodeReasonDateBalanceCoulmn E should beFormula
21234565AAAA1-25789.5625789.5O25789.5O{}
32345676BBBB255789.4555789.4E55789.4EAJ
43456788CCCC8-8886.788886.7Q8886.7QBK
54567897EEEE545879.5245879.5B45879.5BCL
6DM
7EN
8FO
9GP
10HQ
11IR
Sheet1
Cell Formulas
RangeFormula
G2:G5G2=TRUNC(ABS(E2), 1)&INDEX($J$2:$K$11, 1+MOD(ABS(E2)*100, 10), 1+(E2<0))
 
Last edited:
Upvote 1
Solution
I ran into a problem with the first formula, it does not recognize when there is a zero at the end of the number and the negative it added the special character at the end of the negative number not replacing the last digit.

The new option works much better and so far I cannot find any flaws.

Thank you so much for your help!
 
Upvote 0
I ran into a problem with the first formula, it does not recognize when there is a zero at the end of the number and the negative it added the special character at the end of the negative number not replacing the last digit.

The new option works much better and so far I cannot find any flaws.

Thank you so much for your help!
Are you sure? What happens with values of .0#?
Book1
ABCD
1-50756.0250756.02K50756Q
Sheet4
Cell Formulas
RangeFormula
B1B1=LEFT(ABS(A1),LEN(A1)-1)&LOOKUP(RIGHT(A1,1)*1,$N$2:$N$11,IF(A1>=0,$O$2:$O$11,$P$2:$P$11))
D1D1=TRUNC(ABS(A1), 1)&INDEX($Q$2:$R$11, 1+MOD(ABS(A1)*100, 10), 1+(A1<0))


See col D for felix's formula. It got the last digit right for the character, but then it removed the .0 before the last digit. Is that the desired outcome? Should it be 50756.0Q?
 
Upvote 0
Quick question.
If I wanted to use the same (the new one you resorted) matrix and apply replacing the last digit of the Date number in the spreadsheet keeping it three digits what would that look like?
001 would be 00A
-012 would be 01K
-005 would be 00N

Loan NumberCodeReasonDate
1234565AAAA001
2345676BBBB-012
3456788CCCC008
4567897EEEE-005
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top