邮件已于2009.9.20 7:19发送,请版主查收
收到 ——ldy
- '论坛ID:smhf_6 结果正确 但速度未达标 +2
- Function N2Char26R(ByVal L As String) As Double
- '要求不仅限于 2003的IV(256) 和 2007 的XFD(16384列)
- '具体要求请运行 验证1
- Dim ch%, i%, p%
- ch = Len(L)
- L = UCase(L)
- For i = 1 To ch
- p = Application.Lookup(Mid(L, i, 1), [{"A",1;"B",2;"C",3;"D",4;"E",5;"F",6;"G",7;"H",8;"I",9;"J",10;"K",11;"L",12;"M",13;"N",14;"O",15;"P",16;"Q",17;"R",18;"S",19;"T",20;"U",21;"V",22;"W",23;"X",24;"Y",25;"Z",26}])
- N2Char26R = N2Char26R + p * 26 ^ (ch - i)
- Next
- End Function
-
- Function N2Char26(ByVal L As Double) As String
- '你的代码 要求EXCEL2003下可运行
- '具体要求请运行 验证2
-
- Dim i As Integer
- Dim b(26) As Byte
- Dim s As String
- Do Until L = 0
- ' b(i) = L Mod 26 ' 当L>2147483647时出错,“溢出”
- b(i) = L - 26 * Int(L / 26) ' 除26取余
- ' L = L \ 26 ' 当L>2147483647时出错,“溢出”
- L = Int(L / 26)
-
- If b(i) = 0 And L > 0 Then
- b(i) = 26
- L = L - 1
- End If
- i = i + 1
- Loop
- Do While i > 0
- i = i - 1
- p = Choose(b(i), "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
- s = s & p ' 反序排列
- Loop
- N2Char26 = s
- End Function
复制代码
[ 本帖最后由 ldy 于 2009-10-21 17:00 编辑 ] |