Convert numeric characters to alphabetic characters

前端 未结 5 1369
日久生厌
日久生厌 2021-01-02 16:12

I am trying to get I/O as follows:

Input : 123490
Output : BCDEJA

Logic is simple:

if
strarr(i)=0,1,2

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 16:39

    Make use of the ASCII character numbers (...?) and adjust them by the digits you are converting. A capitol A is ASCII 0×41 or 65 dec.

    Function num_alpha(str As String)
        Dim sTMP As String, d As Long
    
        For d = 1 To Len(str)
            sTMP = sTMP & Chr(65 + Mid(str, d, 1))
        Next d
    
        num_alpha = sTMP
    
    End Function
    

    Use like any native worksheet function. In D18 as,

    =num_alpha(B18)
    

          

提交回复
热议问题