|
楼主 |
发表于 2012-4-3 19:12
|
显示全部楼层
最终解决问题的代码如下:- Sub test2()
- tms = Timer
-
- Dim i&, j%, k%, l&
- Sheets(1).[f2].Resize(65535, 5) = ""
-
- arr = Sheets(1).[a1].CurrentRegion
- Set d = CreateObject("Scripting.Dictionary")
- s = Array("万", "千", "百", "十", "个")
- For i = 2 To UBound(arr)
- arr(i, 6) = ""
- arr(i, 7) = ""
- arr(i, 8) = ""
- For j = 1 To 5
- If arr(i, j) = "" Then
- arr(i, 8) = arr(i, 8) & "_"
- Else
- arr(i, 6) = arr(i, 6) & Chr(64 + j)
- arr(i, 7) = arr(i, 7) & s(j - 1)
- arr(i, 8) = arr(i, 8) & arr(i, j)
- End If
- Next
- d(arr(i, 8)) = 1
- Next
- Sheets(1).[a1].CurrentRegion = arr
-
- ' MsgBox Timer - tms
- ' tms = Timer
-
- Dim a%(4)
- Dim b(65535, 0)
- Dim c(9)
-
- For j = 0 To 4
- a(j) = 0
- Next
- a(4) = -1
- For i = 0 To 99999
- For j = 4 To 0 Step -1
- If a(j) < 9 Then
- a(j) = a(j) + 1: Exit For
- Else
- a(j) = 0
- End If
- Next
- c(0) = a(0) & a(1) & a(2) & "__"
- c(1) = a(0) & a(1) & "_" & a(3) & "_"
- c(2) = a(0) & a(1) & "__" & a(4)
- c(3) = a(0) & "_" & a(2) & a(3) & "_"
- c(4) = a(0) & "_" & a(2) & "_" & a(4)
- c(5) = a(0) & "__" & a(3) & a(4)
- c(6) = "_" & a(1) & a(2) & a(3) & "_"
- c(7) = "_" & a(1) & a(2) & "_" & a(4)
- c(8) = "_" & a(1) & "_" & a(3) & a(4)
- c(9) = "__" & a(2) & a(3) & a(4)
-
- k = 0
- For j = 0 To 9
- k = k + d(c(j))
- Next
- If k = 10 Then
- b(l, 0) = "'" & Right("0000" & i, 5): l = l + 1
- End If
- Next
- Sheets(1).[j2].Resize(l) = b
-
- MsgBox Timer - tms
-
- End Sub
复制代码 |
|