Sub test()
Dim Arr, xD, i&, j&, x%
Set xD = CreateObject("Scripting.Dictionary")
Arr = Range([A1], [L65536].End(3))
For i = 1 To UBound(Arr)
For x = 1 To 24: xD(x & "") = "": Next
For j = 1 To UBound(Arr, 2)
xD.Remove (Arr(i, j) & "")
Next
Cells(i, 15).Resize(1, xD.Count) = xD.keys
xD.RemoveAll
Next
End Sub作者: f00l01 時間: 2021-4-23 09:36
結果顯示在同一格,請測試看看,謝謝。
Sub test2()
Dim Arr, xD, i&, j&, x%
Set xD = CreateObject("Scripting.Dictionary")
Arr = Range([A1], [L65536].End(3))
For i = 1 To UBound(Arr)
For x = 1 To 24: xD(x & "") = "": Next
For j = 1 To UBound(Arr, 2)
xD.Remove (Arr(i, j) & "")
Next
Arr(i, 1) = Join(xD.keys, ",")
xD.RemoveAll
Next
Range("n1").Resize(UBound(Arr)) = Arr
End Sub作者: f00l01 時間: 2021-4-23 11:13
Option Explicit
Sub TEST_1()
Dim Brr, i&, j%, y&, x%, V&, u%, R&, C%, A$
Brr = [A1].CurrentRegion: y = UBound(Brr): x = 12
For i = 1 To y
For j = 1 To x: A = A & "/" & Brr(i, j): Next
For j = 1 To 24
If InStr(A & "/", "/" & j & "/") = 0 Then
C = C + 1: Brr(i, C) = j
End If
Next
A = "": C = 0
Next
[O1].Resize(y, 12) = Brr
End Sub
Sub TEST_2()
Dim Brr, Crr, i&, j%, y&, x%, C%, Z
Set Z = CreateObject("Scripting.Dictionary")
Brr = [A1].CurrentRegion
ReDim Crr(1 To UBound(Brr), 1 To 24)
For i = 1 To UBound(Brr)
For j = 1 To 24
If j <= UBound(Brr, 2) Then Z(Brr(i, j)) = 1
If Z(j) = "" Then: C = C + 1: Crr(i, C) = j
Next
Z.RemoveAll: C = 0
Next
[O1].Resize(UBound(Brr), 12) = Crr
End Sub
Sub TEST_3()
Dim Brr, Crr, i&, j%, y&, x%, C%, Z, A%, B%, D%
Set Z = CreateObject("Scripting.Dictionary")
Brr = [A1].CurrentRegion: A = 1
ReDim Crr(1 To UBound(Brr), 1 To 24)
For i = 1 To UBound(Brr)
For j = 1 To 24
If j <= UBound(Brr, 2) Then Z(Brr(i, j)) = A
If Z(j) = B Then: C = C + 1: Crr(i, C) = j: Z(j) = A
Next
D = A: A = B: B = D: C = 0
Next
[O1].Resize(UBound(Brr), 12) = Crr
End Sub作者: Andy2483 時間: 2023-11-8 14:18
Sub TEST_4()
Dim Brr, i&, j%, C%, Z
Set Z = CreateObject("Scripting.Dictionary")
Brr = [A1].CurrentRegion
For i = 1 To UBound(Brr)
For j = 1 To 24
If j <= UBound(Brr, 2) Then Z(Brr(i, j)) = i
If Z(j) <> i Then: C = C + 1: Brr(i, C) = j
Next
C = 0
Next
[O1].Resize(UBound(Brr), 12) = Brr
End Sub作者: hcm19522 時間: 2023-11-9 11:12