Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Incrementing a number with non-decimal base

Hey guys,

I am new to all this so I hope you can help me. I need a function / macro
that will increment a number with a non-decimal base??

My base number is:0123456789BCDFGHJKLMNPQRSTVWXYZ
I an using a 4 digit number.

So for example I need to put in BCR0 and have it run an increment
BCR1
BCR2
BCR3
BCR4
BCR5
BCR6
BCR7
BCR8
BCR9
BCRB
BCRC
BCRD
BCRF
and so on.

Please let me know if and how this can be done in Excel

Many Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Incrementing a number with non-decimal base


Maybe this is not the best way to do this but its an idea..

Dim X as Variant

x=0
Do while condicion
if isnumeric(x) then
if x=9 then
x="a"
else
x=x+1
end if
else
if x="z" then
x=0
else
x=chr(asc(x)+1)
end if
end if
Loop

BRgds.


--
dbarelli
------------------------------------------------------------------------
dbarelli's Profile: http://www.excelforum.com/member.php...o&userid=31275
View this thread: http://www.excelforum.com/showthread...hreadid=514372

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Incrementing a number with non-decimal base

Patrick

As the number sequence is not linear ie there are missing letter it is a
little more difficult. A possible solution is:

Function incnum(ByVal n As String) As String
Dim seq As Variant
Dim ans As String
Dim idx As Integer
seq = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", _
"B", "C", "D", "F", "G", "H", "J", "K", "L", "M", _
"N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", _
"Z", "!") ' use a extra stopper !
n = UCase(Trim(n))
If (Len(n) = 0) Then ' deal with the empty string
incnum = seq(LBound(seq) + 1) ' generally adding 1 to Z
Exit Function
Else ' otherwise find the number
For idx = LBound(seq) To UBound(seq) - 1
If (Right(n, 1) = seq(idx)) Then ' deal with the max number
ans = seq(idx + 1)
If ans = seq(UBound(seq)) Then
incnum = incnum(Left(n, Len(n) - 1)) & "0" ' and then
recursively call
Else
incnum = Left(n, Len(n) - 1) & ans ' normal increment
End If
Exit Function
End If
Next idx
End If
End Function

------

--
HTHs Martin


"Patrick" wrote:

Hey guys,

I am new to all this so I hope you can help me. I need a function / macro
that will increment a number with a non-decimal base??

My base number is:0123456789BCDFGHJKLMNPQRSTVWXYZ
I an using a 4 digit number.

So for example I need to put in BCR0 and have it run an increment
BCR1
BCR2
BCR3
BCR4
BCR5
BCR6
BCR7
BCR8
BCR9
BCRB
BCRC
BCRD
BCRF
and so on.

Please let me know if and how this can be done in Excel

Many Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Incrementing a number with non-decimal base

That is fancastic, thank you Martin.

May be back with another one...

"Martin Fishlock" wrote:

Patrick

As the number sequence is not linear ie there are missing letter it is a
little more difficult. A possible solution is:

Function incnum(ByVal n As String) As String
Dim seq As Variant
Dim ans As String
Dim idx As Integer
seq = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", _
"B", "C", "D", "F", "G", "H", "J", "K", "L", "M", _
"N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", _
"Z", "!") ' use a extra stopper !
n = UCase(Trim(n))
If (Len(n) = 0) Then ' deal with the empty string
incnum = seq(LBound(seq) + 1) ' generally adding 1 to Z
Exit Function
Else ' otherwise find the number
For idx = LBound(seq) To UBound(seq) - 1
If (Right(n, 1) = seq(idx)) Then ' deal with the max number
ans = seq(idx + 1)
If ans = seq(UBound(seq)) Then
incnum = incnum(Left(n, Len(n) - 1)) & "0" ' and then
recursively call
Else
incnum = Left(n, Len(n) - 1) & ans ' normal increment
End If
Exit Function
End If
Next idx
End If
End Function

------

--
HTHs Martin


"Patrick" wrote:

Hey guys,

I am new to all this so I hope you can help me. I need a function / macro
that will increment a number with a non-decimal base??

My base number is:0123456789BCDFGHJKLMNPQRSTVWXYZ
I an using a 4 digit number.

So for example I need to put in BCR0 and have it run an increment
BCR1
BCR2
BCR3
BCR4
BCR5
BCR6
BCR7
BCR8
BCR9
BCRB
BCRC
BCRD
BCRF
and so on.

Please let me know if and how this can be done in Excel

Many Thanks


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting from Decimal to Base-36 in Excel Formula Jason Tram Excel Worksheet Functions 7 December 11th 19 09:27 PM
incrementing sheet number iain_greenan Excel Discussion (Misc queries) 4 November 11th 08 04:29 PM
formulat to convert base 32 to decimal? TMG005 Excel Worksheet Functions 5 July 15th 07 10:31 PM
Converting 2-place decimal value to floating point decimal number with leading zero Kermit Piper Excel Discussion (Misc queries) 3 March 18th 06 06:20 PM
Incrementing a formula by X number Bowbender Excel Worksheet Functions 3 September 21st 05 04:14 PM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"