Breaking split at not 0

Lavina

Board Regular
Joined
Dec 18, 2018
Messages
75
Hello guys,

I have a sequence:
00000001
00000005
00000009
00000013
00000017
00000021

<colgroup><col></colgroup><tbody>
</tbody>

I want to extend it indefinitely, well until it fits, but i was not sure what the best approach would be.
I was thinking of taking it as a string and use split to the first non 0, then turn that into a long add 4 to it and then switch it into a string and fill it up with 0 to make it an 8 digit. But i was unsure of how i can formulate my split. Any ideas? Or maybe a better approach?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Assuming the first value is in A2, try this in A3 & copy down
=TEXT(A2+4,"00000000")
 
Upvote 0
or A2: =BASE(A1+4,10,8) where A1: 00000001
I am guessing BASE was added in one of the more recent versions of Excel... I am using XL2010 and it is not in my version. Fluff had alread posted the formula that I was going to post.
 
Last edited:
Upvote 0
BASE function

Excel for Office 365 Excel for Office 365 for Mac Excel for the web Excel 2019 Excel 2016 Excel 2019 for Mac Excel 2013 Excel 2016 for Mac Excel for Mac 2011

Post #1 does not contain Excel version
 
Last edited:
Upvote 0
BASE function

Excel for Office 365 Excel for Office 365 for Mac Excel for the web Excel 2019 Excel 2016 Excel 2019 for Mac Excel 2013 Excel 2016 for Mac Excel for Mac 2011

Post #1 does not contain Excel version

Thanks for the info. Strange... the Mac versions of Excel got the BASE function years before the Windows version?
 
Upvote 0
Sorry guys, slacked off on creating a proper question, thank you for your input though.

Since i needed jumps to happen at specific times i ended up with something like this:

Code:
Sub Sequence()
Dim lastRow As Long, i As Long, currentNumber As Long
lastRow = Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
currentNumber = 1
For i = 2 To lastRow
Cells(i, 14) = currentNumber
    If Cells(i, 14) = Len(Cells(i, 14)) <> 12 Then
        For j = 1 To 12 - Len(Cells(i, 14))
        Cells(i, 14) = "0" & Cells(i, 14)
        Next j
    End If
currentNumber = currentNumber + 5
If Cells(i, 8) <> Cells(i + 1, 8) Then currentNumber = currentNumber + 100
If Cells(i, 5) <> Cells(i + 1, 5) Then currentNumber = currentNumber + 200
Next i
End Sub
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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