- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-12-27 12:17 ½s¿è
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æ«e: °õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim Brr, Z, i&, j%, sR As Range, eR As Range, xR As Range
With ActiveSheet.UsedRange
Intersect(.Offset(0, 7), .Offset(4, 0)).Delete Shift:=xlUp
End With
Set Z = CreateObject("Scripting.Dictionary")
Brr = Range([A1], [C5].End(xlDown)(2, 2))
For i = 1 To UBound(Brr)
If Trim(Brr(i, 1)) <> "" Or i = UBound(Brr) Then
Set sR = eR: Set eR = Cells(i, 1)
If Not sR Is Nothing Then
Z(sR & "") = Range(sR(1, 2), eR(0, 4))
Z(sR & "/r") = eR.Row - sR.Row
End If
End If
Next
Brr = Range([C35], [B65536].End(xlUp)): Set xR = [H5]
For i = 1 To UBound(Brr)
If Brr(i, 2) = "¬O" Then
With xR.Resize(Z(Brr(i, 1) & "/r"), 3)
.Value = Z(Brr(i, 1))
.Rows(1).Font.Bold = True
For j = 7 To 10: .Borders(j).Weight = 4: Next
End With
Set xR = xR(Z(Brr(i, 1) & "/r") + 1, 1)
End If
Next
End Sub
'==========================================================
¥H¤U¬O²Õ§O¤]±a¤Jªº¤è®×
°õ¦æ«e: °õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim ¸ê®Æ°}¦C, ¨ì¶Ô±±¨î°}¦C, ¦r¨å, i&, j%, °_©l®æ As Range, µ²§ô®æ As Range, µ²ªG°_©l®æ As Range
With ActiveSheet.UsedRange
Intersect(.Offset(0, 7), .Offset(4, 0)).Delete Shift:=xlUp
End With
Set ¦r¨å = CreateObject("Scripting.Dictionary")
¸ê®Æ°}¦C = Range([A1], [C5].End(xlDown)(2, 2))
For i = 1 To UBound(¸ê®Æ°}¦C)
If Trim(¸ê®Æ°}¦C(i, 1)) <> "" Or i = UBound(¸ê®Æ°}¦C) Then
Set °_©l®æ = µ²§ô®æ: Set µ²§ô®æ = Cells(i, 1)
If Not °_©l®æ Is Nothing Then
¦r¨å(°_©l®æ & "") = Range(°_©l®æ(1, 1), µ²§ô®æ(0, 4))
¦r¨å(°_©l®æ & "/r") = µ²§ô®æ.Row - °_©l®æ.Row
End If
End If
Next
¨ì¶Ô±±¨î°}¦C = Range([C35], [B65536].End(xlUp)): Set µ²ªG°_©l®æ = [H5]
For i = 1 To UBound(¨ì¶Ô±±¨î°}¦C)
If ¨ì¶Ô±±¨î°}¦C(i, 2) = "¬O" Then
With µ²ªG°_©l®æ.Resize(¦r¨å(¨ì¶Ô±±¨î°}¦C(i, 1) & "/r"), 4)
.Value = ¦r¨å(¨ì¶Ô±±¨î°}¦C(i, 1))
.Rows(1).Font.Bold = True
.Columns(1).Merge
For j = 7 To 10: .Borders(j).Weight = 4: Next
End With
Set µ²ªG°_©l®æ = µ²ªG°_©l®æ(¦r¨å(¨ì¶Ô±±¨î°}¦C(i, 1) & "/r") + 1, 1)
End If
Next
End Sub |
|