ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Numerals conversion (https://www.excelbanter.com/excel-worksheet-functions/448360-numerals-conversion.html)

Luciano[_2_]

Numerals conversion
 
Hi,
Does somebody have any idea about how to develop some VBA function or macro aiming conversion of several numerals types and that could be used for small and large numbers(e.g. 100000000000 in decimal)? The major numerals base for which I need this conversions a
Binary (Base 2)
Ternary (Base 3)
Quaternary (Base 4)
Quinary (Baase 5)
Senary (Base 6)
Septenary (Base 7)
Octal (Base 8)
Nonary (Base 9)
Decimal (Base 10)
Undecimal (Base 11)
Duodecimal (Base 12)
Base 13
Hexadecimal (Base 16)
Vigesimal (Base 20)

Thanks in advance,
Luciano

Living the Dream

Numerals conversion
 
Hi there Luciano

Not sure if I am reading right or not.

Have a look at the following, it may point you in the right direction.

It assumes your numbers you want to convert are in Column "B", so
anytime you enter the base value you have presented the adjacent cell
will change its decimal count to the number entered.

I may have misinterpreted what it is you're needing, but someone else
may have another idea for you to run with.

HTH
Mick.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim r As Long

If Not Intersect(Target, Range("A1:A20")) Is Nothing Then

Select Case True

Case Target.Value = 2
With ActiveCell
.Offset(0, 1).NumberFormat = "0.00"
End With
Case Target.Value = 3
With ActiveCell
.Offset(0, 1).NumberFormat = "0.000"
End With
Case Target.Value = 4
With ActiveCell
.Offset(0, 1).NumberFormat = "0.0000"
End With
Case Target.Value = 5
With ActiveCell
.Offset(0, 1).NumberFormat = "0.00000"
End With
Case Target.Value = 6
With ActiveCell
.Offset(0, 1).NumberFormat = "0.000000"
End With
Case Target.Value = 7
With ActiveCell
.Offset(0, 1).NumberFormat = "0.0000000"
End With
Case Target.Value = 8
With ActiveCell
.Offset(0, 1).NumberFormat = "0.00000000"
End With
Case Target.Value = 9
With ActiveCell
.Offset(0, 1).NumberFormat = "0.000000000"
End With
Case Target.Value = 10
With ActiveCell
.Offset(0, 1).NumberFormat = "0.0000000000"
End With
Case Target.Value = 11
With ActiveCell
.Offset(0, 1).NumberFormat = "0.00000000000"
End With
Case Target.Value = 12
With ActiveCell
.Offset(0, 1).NumberFormat = "0.000000000000"
End With
Case Target.Value = 16
With ActiveCell
.Offset(0, 1).NumberFormat = "0.0000000000000000"
End With
Case Target.Value = 20
With ActiveCell
.Offset(0, 1).NumberFormat = "0.00000000000000000000"
End With
Case Else
r = MsgBox("You Need to enter a number between 2 & 20")

End Select
End If
End Sub


Living the Dream

Numerals conversion
 
Hey there Luciano

I do not respond to direct mail, unless invited.

The reason for this apart from Newsgroup Etiquette is that others whom
may have a similar need miss out.

I see you have a few responses to your other thread so will discontinue
this on.

Cheers
Mick.


All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com