Another possible UDF
Function ShiftZeros(Base As Range, ShiftBy As Long) As String
Dim n As Long, DigitCount As Long
Dim strTmp As String
If ShiftBy = 0 Then
ShiftZeros = ""
Exit Function
End If
DigitCount = Len(Base)
If DigitCount > 9 Then
ShiftZeros = "Digit Limit = 9"
Exit Function
End If
ReDim BaseArray(DigitCount)
For n = 1 To DigitCount
BaseArray(n) = n
Next
ReDim tmpArray(DigitCount)
For n = 1 To DigitCount
If Mid(Base, n, 1) > 0 Then
tmpArray(n) = 0
Else
If (n + ShiftBy) Mod DigitCount = 0 Then
tmpArray(n) = DigitCount
Else
tmpArray(n) = (n + ShiftBy) Mod DigitCount
End If
End If
Next
For n = 1 To DigitCount
If tmpArray(n) > 0 Then BaseArray(tmpArray(n)) = 0
Next
For n = 1 To DigitCount
ShiftZeros = ShiftZeros & BaseArray(n)
Next
End Function
A bit longer than rylos' but this will handle text based numbers with 1 to 9 digits.
Bookmarks