Excel で数値を Base 10 から Base 36 に変換する簡単な方法はありますか? 変換する必要がある 2,000 を超える数値のリストがあるため、オンライン コンバーターの 1 つで 1 つずつ変換することはできません。
数学的な方法があっても、数式を使用できると考えていました。
より良い解決策は、BASE関数を使用することです
=Base(変換する数値,base)
例えば
=base(35,36) = Z
=ベース(36,36) = 10
これを見てください:
http://www.thetropicalevents.com/Xnumbers60/
http://www.thetropicalevents.com/Xnumbers60.htm
[Korem の要求に応じてコードを追加]
また
Sub main()
Dim base10Number As Double
base10Number = Int(Rnd * 1000)
Debug.Print base10Number, ConvertBase10(base10Number, "0123456789ABCDEF")
End Sub
Public Function ConvertBase10(ByVal d As Double, ByVal sNewBaseDigits As String) As String
Dim S As String, tmp As Double, i As Integer, lastI As Integer
Dim BaseSize As Integer
BaseSize = Len(sNewBaseDigits)
Do While Val(d) <> 0
tmp = d
i = 0
Do While tmp >= BaseSize
i = i + 1
tmp = tmp / BaseSize
Loop
If i <> lastI - 1 And lastI <> 0 Then S = S & String(lastI - i - 1, Left(sNewBaseDigits, 1)) 'get the zero digits inside the number
tmp = Int(tmp) 'truncate decimals
S = S + Mid(sNewBaseDigits, tmp + 1, 1)
d = d - tmp * (BaseSize ^ i)
lastI = i
Loop
S = S & String(i, Left(sNewBaseDigits, 1)) 'get the zero digits at the end of the number
ConvertBase10 = S
End Function
http://www.freevbcode.com/ShowCode.asp?ID=6604からコピー
または類似....
=ConvertBase10(A1,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Sub main()
Dim MyNumber As Double
MyNumber = 999999999999999#
MsgBox MyNumber & ": " & ConvertBase10(MyNumber, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
End Sub
Public Function ConvertBase10(ByVal d As Double, ByVal sNewBaseDigits As String) As String
Dim S As String, tmp As Double, i As Integer, lastI As Integer
Dim BaseSize As Integer
BaseSize = Len(sNewBaseDigits)
Do While Val(d) <> 0
tmp = d
i = 0
Do While tmp >= BaseSize
i = i + 1
tmp = tmp / BaseSize
Loop
If i <> lastI - 1 And lastI <> 0 Then S = S & String(lastI - i - 1, Left(sNewBaseDigits, 1)) 'get the zero digits inside the number
tmp = Int(tmp) 'truncate decimals
S = S + Mid(sNewBaseDigits, tmp + 1, 1)
d = d - tmp * (BaseSize ^ i)
lastI = i
Loop
S = S & String(i, Left(sNewBaseDigits, 1)) 'get the zero digits at the end of the number
ConvertBase10 = S
End Function