REPLACE VALUES WITH WEIGHTED LETTERS FROM TABLE

agur

New Member
Joined
Jul 21, 2002
Messages
5
IF I ENTER AN AMOUNT OF 1234.00 (FORMATED TO TWO DECIMAL PLACES) IN CELL A1 I WANT TO WRITE A FORMULAR IN CELL B1 TO RETURN THE COMBINATION OF LETTERS FROM THE KEY BELOW : –

0 = W
1 = O
2 = R
3 = S
4 = H
5 = I
6 = P
7 = F
8 = U
9 = N

FOR EXAMPLE IF I ENTERED 1234.00 IN CELL A1 IT MUST RETURN THE COMBINATION OF LETTERS ORSHWW IN CELL B1 OR IF I ENTERED THE VALUE 786.58 IT MUST RETURN THE COMBINATION FUPIU IN B1 (SUBSTITUTE THE VALUES WITH LETTERS FROM THE ABOVE TABLE) GET THE PICTURE!!

I ANXIOUSLY AWAIT YOUR REPLY.

REGARDS

ANAND GURAYAH

Juan - forgive me for being an idiot WHAT DO YOU MEAN WHEN YOU SAY YOU HAVE PM THE UDF - WOULD APRECIATE IT IF YOU COULD DETAIL THE PROCESS FOR ME STEP BY STEP.

REGARDS

AG
This message was edited by agur on 2002-08-14 00:13
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Anand. What about the . ? that gets eliminated ? I have an UDF that can do what you want, but I have it at home. Just trying to get a little ahead.
 
Upvote 0
On 2002-08-12 14:10, Juan Pablo G. wrote:
Anand. What about the . ? that gets eliminated ? I have an UDF that can do what you want, but I have it at home. Just trying to get a little ahead.

=MSUBSTITUTE(SUBSTITUTE(target-val,".",""),...)

Wait indeed for Juan for MSUBSTITUTE. I'm just soothing him about the dot.

PS. Juan: Lost my test file. Working on it. :)

Aladin
 
Upvote 0
On 2002-08-12 14:15, agur wrote:
WILL YOU MAKE THE UDF AVAILABLE AND TELL ME HOW TO USE IT - WHAT'S A UDF

Yes, but when I get home. It works "pretty" much the same way as SUBSTITUTE but has the option to substitute multiple characters at once, which is exactly what you need. And Aladin already provided a solution for the dot.
 
Upvote 0
I've PM the code for the UDF. To use it, open your workbook, press Alt F11, press Alt IM, and paste the code in there.

Now, go back to Excel. And here's an example.

The cell B11 is empty. And A11 has a .
Libro2
ABCDE
10W1234.00ORSHWW
21O786.58FUPIU
32R
43S
54H
65I
76P
87F
98U
109N
11.
Hoja1
 
Upvote 0
A UDF is a function that is designed by the user (User Defined Function), and not built-in in Excel. It's basically a macro that returns a value after performing certain tasks.
 
Upvote 0
On 2002-08-12 14:15, Aladin Akyurek wrote:
On 2002-08-12 14:10, Juan Pablo G. wrote:
Anand. What about the . ? that gets eliminated ? I have an UDF that can do what you want, but I have it at home. Just trying to get a little ahead.


1. ignoring the "."
2. wait for a sophisticated solution

try
=VLOOKUP(LEFT(A2*100),rL,2)&VLOOKUP(MID(A2*100,2,1),rL,2)&VLOOKUP(MID(A2*100,3,1),rL,2)&VLOOKUP(MID(A2*100,4,1),rL,2)&VLOOKUP(MID(A2*100,5,1),rL,2)&VLOOKUP(MID(A2*100,6,1),rL,2)&VLOOKUP(MID(A2*100,7,1),rL,2)
 
Upvote 0
Dave, here it is.

Code:
Function MSUBSTITUTE(text As Variant, old_text As Variant, new_text As Variant) As Variant
    'Version 2.  Aug 12/2002
    Dim vNew As Variant
    Dim vOld As Variant
    Dim vText As Variant
    Dim iRow As Long
    Dim iCol As Integer
    Dim j As Integer
    
    If IsArray(old_text) Then
    vOld = old_text
    vNew = new_text
    
    If UBound(vOld, 1) > 1 And UBound(vOld, 2) > 1 Then
    'Must be a 1D array
    MSUBSTITUTE = CVErr(xlErrNum)
    Exit Function
    End If
    
    If IsArray(vNew) Then
    If UBound(vOld, 1)<> UBound(vNew, 1) Or UBound(vOld, 2)<> UBound(vNew, 2) Then
    'Different arrays, can't do this
    MSUBSTITUTE = CVErr(xlErrNum)
    Exit Function
    End If
    End If
    
    'Is column, transpose to row
    If UBound(vOld, 2) > 1 Then
    vOld = Application.Transpose(vOld)
    End If
    
    If IsArray(vNew) Then
    If UBound(vNew, 2) > 1 Then
    vNew = Application.Transpose(vNew)
    End If
    
    ReDim Preserve vNew(1 To UBound(vOld, 1), 1 To 1)
    Else
    ReDim vNew(1 To UBound(vOld, 1), 1 To 1)
    For iRow = 1 To UBound(vOld, 1)
    vNew(iRow, 1) = new_text
    Next iRow
    End If
    
    Else
    ReDim vOld(1 To Len(old_text), 1 To 1)
    ReDim vNew(1 To Len(old_text), 1 To 1)
    
    For iRow = 1 To Len(old_text)
    vOld(iRow, 1) = Mid(old_text, iRow, 1)
    If Mid(new_text, iRow, 1)<> "" Then
    vNew(iRow, 1) = Mid(new_text, iRow, 1)
    Else
    vNew(iRow, 1) = ""
    End If
    Next iRow
    
    End If
    If IsArray(text) Then
    vText = text
    For iRow = LBound(vText, 1) To UBound(vText, 1)
    For iCol = LBound(vText, 2) To UBound(vText, 2)
    For j = 1 To UBound(vOld, 1)
    vText(iRow, iCol) = Application.Substitute(vText(iRow, iCol), vOld(j, 1), vNew(j, 1))
    Next j
    Next iCol
    Next iRow
    Else
    vText = text
    For j = 1 To UBound(vOld, 1)
    vText = Application.Substitute(vText, vOld(j, 1), vNew(j, 1))
    Next j
    End If
    MSUBSTITUTE = vText
End Function

_________________
Regards,

Juan Pablo G.
MrExcel.com Consulting
This message was edited by Juan Pablo G. on 2002-08-12 15:23
 
Upvote 0

Forum statistics

Threads
1,215,862
Messages
6,127,386
Members
449,382
Latest member
DonnaRisso

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