'凑了一个,条件好象多了,规则也不唯一,,,
Option Explicit
Const NUM As Long = 2000
Sub test()
Dim s As String, i As Long, mark, m As Long, n As Long, p As Long, a, b, c, d, t, cnt
t = Timer
mark = Split("0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z", ",")
a = c34to10(Right([d4].Value, 2), mark): b = c34to10(Right([d5].Value, 2), mark)
c = Left([d4].Value, Len([d4].Value) - 2): d = Left([d5].Value, Len([d5].Value) - 2)
ReDim arr(1 To NUM, 1 To (d - c + 1) / NUM + 1) As String
m = 0: n = 1: s = [c4].Value
For i = c To d
m = m + 1: p = a + cnt
Do
arr(m, n) = mark(p Mod 34) & arr(m, n)
p = p \ 34
Loop Until p = 0
arr(m, n) = s & i & arr(m, n)
If m = NUM Then m = 0: n = n + 1
cnt = cnt + 1
Next
Debug.Print Timer - t, m, n
[g3].Resize(NUM, n) = arr
Debug.Print Timer - t
End Sub
Function c34to10(s, mark) As Long
Dim i, n As Long, dic
Set dic = CreateObject("scripting.dictionary")
For i = 0 To UBound(mark)
dic(mark(i)) = i
Next
s = UCase(s)
For i = 1 To Len(s)
n = n + dic(Mid(s, i, 1)) * 34 ^ (Len(s) - i)
Next
c34to10 = n
End Function |