- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-3
|
¦^´_ 11# aassddff736
¨Ì·ÓAÄæ±Æ§Ç,¦Û°Ê½Õ¾ãÄæ¼e,¨Ì¸ê®ÆA,B¹ï·Ó¦WºÙ¬°¼Ð¦C,¥t¦s®t²§°O¿ý¶·¦Û¤v¦sÀÉ ¤è®×¦p¤U:
³]©wªí:
Option Explicit
Private Sub CommandButton1_Click()
Dim Arr, Brr, Crr, C%, Z, N&, i&, j%, R&, Ta$, Tb$, xR As Range, xB As Range, xS As Worksheet
Set Z = CreateObject("Scripting.Dictionary"): Set xS = Sheets("¤ñ¹ïµ²ªG")
Set Arr = Sheets("¸ê®ÆA").[A1].CurrentRegion: Arr = Union(Arr, Arr.Offset(, 1))
Set Brr = Sheets("¸ê®ÆB").[A1].CurrentRegion: Brr = Union(Brr, Brr.Offset(, 1))
C = UBound(Arr, 2): If C <> UBound(Brr, 2) Then [B6:B8] = "": [B9] = 0: [B10] = 0: MsgBox "Äæ¼Æ¤£¦P": Exit Sub
ReDim Crr(1 To (UBound(Arr) + UBound(Brr)), 1 To C * 2 + 1)
For i = 1 To UBound(Arr)
Ta = Trim(Arr(i, 1)): R = R + 1: Z(Ta) = R: Crr(R, 1) = Ta
For j = 1 To C: Crr(R, j + 1) = Arr(i, j): Next
Next
For i = 1 To UBound(Brr)
Tb = Trim(Brr(i, 1)): N = Z(Tb): If N = 0 Then R = R + 1: Crr(R, 1) = Tb: N = R: Z(Tb) = R
For j = 1 To C: Crr(N, j + 1 + C) = Brr(i, j): Next
Next
Application.Goto xS.[A1]
xS.UsedRange.EntireRow.Delete: xS.[A1] = "NUMBER"
With xS.[A2].Resize(R, C * 2 + 1): .Value = Crr: .Sort KEY1:=.Item(1), Order1:=1, Header:=2: Crr = .Value: End With
xS.[B1] = [³]©w!B2]: xS.[B1].Resize(, C - 1).Merge: xS.[B1].Item(, C + 1) = [³]©w!B3]: xS.[B1].Item(, C + 1).Resize(, C - 1).Merge
xS.UsedRange.EntireColumn.AutoFit: Set xR = xS.UsedRange: Set xR = xR(xR.Count + 1): Set xB = xR: xS.[1:1].HorizontalAlignment = xlCenter
For i = 2 To R + 1
For j = 3 To C
Set xR = IIf(Crr(i - 1, j) <> Crr(i - 1, j + C), Union(xR, xS.Cells(i, j), xS.Cells(i, 1)), xR)
If Crr(i - 1, j) = "" Or Crr(i - 1, j + C) = "" Then Set xB = Union(xB, xS.Cells(i, j))
Next
Next
Union(xR, xR.Offset(, C)).Font.ColorIndex = 3
xB.EntireRow.Font.ColorIndex = 5
With Sheets("¯d¤U¬Û¦P")
.UsedRange.EntireRow.Delete: xS.UsedRange.Copy .[A1]: .UsedRange.EntireColumn.AutoFit
.Range(Intersect(xR.EntireRow, xS.UsedRange).Address).EntireRow.Delete
End With
With Sheets("¯d¤U®t²§")
.UsedRange.EntireRow.Delete: Intersect(Union(xS.[A1], xR.EntireRow), xS.UsedRange).EntireRow.Copy .[A1]: .UsedRange.EntireColumn.AutoFit
End With
[B6] = C - 1: [B7] = UBound(Arr): [B8] = UBound(Brr): [B9] = 1: [B10] = 1
End Sub
Private Sub CommandButton2_Click()
Sheets("¸ê®ÆA").UsedRange.EntireRow.Interior.ColorIndex = 36 'Delete
Sheets("¸ê®ÆB").UsedRange.EntireRow.Interior.ColorIndex = 36 'Delete
Sheets("¤ñ¹ïµ²ªG").UsedRange.EntireRow.Interior.ColorIndex = 36 'Delete
Sheets("¯d¤U¬Û¦P").UsedRange.EntireRow.Interior.ColorIndex = 36 'Delete
Sheets("¯d¤U®t²§").UsedRange.EntireRow.Interior.ColorIndex = 36 'Delete
End Sub
Private Sub CommandButton3_Click()
Sheets("¸ê®ÆA").UsedRange.EntireRow.Interior.ColorIndex = 6 'Delete
Sheets("¸ê®ÆB").UsedRange.EntireRow.Interior.ColorIndex = 6 'Delete
End Sub
Private Sub CommandButton4_Click()
Sheets("¯d¤U®t²§").Copy
End Sub |
|