- ©«¤l
- 228
- ¥DÃD
- 73
- ºëµØ
- 2
- ¿n¤À
- 333
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 10
- ³nÅ骩¥»
- Office 2000, 2019
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¹ü¤Æ¿¤
- µù¥U®É¶¡
- 2013-7-18
- ³Ì«áµn¿ý
- 2024-10-13
|
§Úªº¥N½X¡A¥iÀ°¦£Àu¤Æ¶Ü¡HÁÂÁ¡I
Option Explicit
Option Base 1
Option Compare Text
Public Sub S_¤Gºû°}¦C§Ö³téw»¼¼W±Æ§Ç_01(ByRef ì©l¤Gºû°}¦C As Variant, ByVal ±Æ§Çºû«× As Long, ByVal ±Æ§Ç¤¸¯À§Ç As Long, ByVal °_ As Long, ByVal ¨´ As Long)
On Error Resume Next
Dim N As Long
Dim H As Long
Dim K As Long
Dim X As Long
Dim Y As Long
Dim °}¦C¼Æ As Long
Dim °ò·Ç As Variant
Dim ì©l¤Gºû°}¦C¼Æ As Long
Dim °}¦C²Öp¼Æ As Long
Dim °_°}¦C() As Variant
Dim ¨´°}¦C() As Variant
Dim °ò°}¦C() As Variant
°}¦C¼Æ = ¨´ - °_ + 1
If °}¦C¼Æ < 2 Then
Exit Sub
End If
If ±Æ§Çºû«× = 1 Then
°ò·Ç = ì©l¤Gºû°}¦C((°_ + ¨´) \ 2, ±Æ§Ç¤¸¯À§Ç)
ì©l¤Gºû°}¦C¼Æ = UBound(ì©l¤Gºû°}¦C, 2) - LBound(ì©l¤Gºû°}¦C, 2) + 1
ReDim °_°}¦C(°}¦C¼Æ - 1, ì©l¤Gºû°}¦C¼Æ) As Variant
ReDim ¨´°}¦C(°}¦C¼Æ - 1, ì©l¤Gºû°}¦C¼Æ) As Variant
ReDim °ò°}¦C(°}¦C¼Æ, ì©l¤Gºû°}¦C¼Æ) As Variant
N = 0
H = 0
K = 0
For X = °_ To ¨´
If ì©l¤Gºû°}¦C(X, ±Æ§Ç¤¸¯À§Ç) < °ò·Ç Then
N = N + 1
For Y = LBound(ì©l¤Gºû°}¦C, 2) To UBound(ì©l¤Gºû°}¦C, 2)
°_°}¦C(N, Y) = ì©l¤Gºû°}¦C(X, Y)
Next Y
ElseIf ì©l¤Gºû°}¦C(X, ±Æ§Ç¤¸¯À§Ç) = °ò·Ç Then
H = H + 1
For Y = LBound(ì©l¤Gºû°}¦C, 2) To UBound(ì©l¤Gºû°}¦C, 2)
°ò°}¦C(H, Y) = ì©l¤Gºû°}¦C(X, Y)
Next Y
Else
K = K + 1
For Y = LBound(ì©l¤Gºû°}¦C, 2) To UBound(ì©l¤Gºû°}¦C, 2)
¨´°}¦C(K, Y) = ì©l¤Gºû°}¦C(X, Y)
Next Y
End If
Next X
If N > 1 Then
S_¤Gºû°}¦C§Ö³téw»¼¼W±Æ§Ç_01 °_°}¦C, 1, ±Æ§Ç¤¸¯À§Ç, 1, N
End If
If K > 1 Then
S_¤Gºû°}¦C§Ö³téw»¼¼W±Æ§Ç_01 ¨´°}¦C, 1, ±Æ§Ç¤¸¯À§Ç, 1, K
End If
°}¦C²Öp¼Æ = 0
For X = °_ To ¨´
°}¦C²Öp¼Æ = °}¦C²Öp¼Æ + 1
If °}¦C²Öp¼Æ <= N Then
For Y = LBound(ì©l¤Gºû°}¦C, 2) To UBound(ì©l¤Gºû°}¦C, 2)
ì©l¤Gºû°}¦C(X, Y) = °_°}¦C(°}¦C²Öp¼Æ, Y)
Next Y
ElseIf °}¦C²Öp¼Æ <= (N + H) Then
For Y = LBound(ì©l¤Gºû°}¦C, 2) To UBound(ì©l¤Gºû°}¦C, 2)
ì©l¤Gºû°}¦C(X, Y) = °ò°}¦C(°}¦C²Öp¼Æ - N, Y)
Next Y
Else
For Y = LBound(ì©l¤Gºû°}¦C, 2) To UBound(ì©l¤Gºû°}¦C, 2)
ì©l¤Gºû°}¦C(X, Y) = ¨´°}¦C(°}¦C²Öp¼Æ - N - H, Y)
Next Y
End If
Next X
Else
°ò·Ç = ì©l¤Gºû°}¦C(±Æ§Ç¤¸¯À§Ç, (°_ + ¨´) \ 2)
ì©l¤Gºû°}¦C¼Æ = UBound(ì©l¤Gºû°}¦C, 1) - LBound(ì©l¤Gºû°}¦C, 1) + 1
ReDim °_°}¦C(ì©l¤Gºû°}¦C¼Æ, °}¦C¼Æ - 1) As Variant
ReDim ¨´°}¦C(ì©l¤Gºû°}¦C¼Æ, °}¦C¼Æ - 1) As Variant
ReDim °ò°}¦C(ì©l¤Gºû°}¦C¼Æ, °}¦C¼Æ) As Variant
N = 0
H = 0
K = 0
For Y = °_ To ¨´
If ì©l¤Gºû°}¦C(±Æ§Ç¤¸¯À§Ç, Y) < °ò·Ç Then
N = N + 1
For X = LBound(ì©l¤Gºû°}¦C, 1) To UBound(ì©l¤Gºû°}¦C, 1)
°_°}¦C(X, N) = ì©l¤Gºû°}¦C(X, Y)
Next X
ElseIf ì©l¤Gºû°}¦C(±Æ§Ç¤¸¯À§Ç, Y) = °ò·Ç Then
H = H + 1
For X = LBound(ì©l¤Gºû°}¦C, 1) To UBound(ì©l¤Gºû°}¦C, 1)
°ò°}¦C(X, H) = ì©l¤Gºû°}¦C(X, Y)
Next X
Else
K = K + 1
For X = LBound(ì©l¤Gºû°}¦C, 1) To UBound(ì©l¤Gºû°}¦C, 1)
¨´°}¦C(X, K) = ì©l¤Gºû°}¦C(X, Y)
Next X
End If
Next Y
If N > 1 Then
S_¤Gºû°}¦C§Ö³téw»¼¼W±Æ§Ç_01 °_°}¦C, 2, ±Æ§Ç¤¸¯À§Ç, 1, N
End If
If K > 1 Then
S_¤Gºû°}¦C§Ö³téw»¼¼W±Æ§Ç_01 ¨´°}¦C, 2, ±Æ§Ç¤¸¯À§Ç, 1, K
End If
°}¦C²Öp¼Æ = 0
For Y = °_ To ¨´
°}¦C²Öp¼Æ = °}¦C²Öp¼Æ + 1
If °}¦C²Öp¼Æ <= N Then
For X = LBound(ì©l¤Gºû°}¦C, 1) To UBound(ì©l¤Gºû°}¦C, 1)
ì©l¤Gºû°}¦C(X, Y) = °_°}¦C(X, °}¦C²Öp¼Æ)
Next X
ElseIf °}¦C²Öp¼Æ <= (N + H) Then
For X = LBound(ì©l¤Gºû°}¦C, 1) To UBound(ì©l¤Gºû°}¦C, 1)
ì©l¤Gºû°}¦C(X, Y) = °ò°}¦C(X, °}¦C²Öp¼Æ - N)
Next X
Else
For X = LBound(ì©l¤Gºû°}¦C, 1) To UBound(ì©l¤Gºû°}¦C, 1)
ì©l¤Gºû°}¦C(X, Y) = ¨´°}¦C(X, °}¦C²Öp¼Æ - N - H)
Next X
End If
Next Y
End If
End Sub |
|