- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¦^´_ 1# c_c_lai
¼g±o®¼¶Ãªº¡A¥]²[«¢~
d1¦r¨å : Address , ±¿n
d2¦r¨å : ±¿n , Ó¼Æ
¨Ì»Ý¨D¦A¦Û¤v§ï§ï§a- Sub test()
- Dim d1, d2, bCombine As Boolean, lCol As Long
- Dim stripe As Range, stripeOffset As Range, rngTarget As Range
-
- Set d1 = CreateObject("scripting.dictionary")
- With Sheets(1).[A1].CurrentRegion
- .Replace What:="0", Replacement:=""
- For lCol = 1 To .Columns.Count
- If Application.CountA(.Columns(lCol).Cells) < .Columns(lCol).Cells.Count Then
- For Each stripe In .Columns(lCol).SpecialCells(xlCellTypeBlanks).Areas
- If stripe.Column = 1 Then
- Set stripeOffset = stripe
- Else
- Set stripeOffset = .Parent.Range(stripe.Address).Offset(0, -1)
- End If
- bCombine = False
- For Each prev In d1.keys
- If Not Application.Intersect(.Parent.Range(prev), stripeOffset) Is Nothing Then
- If d1.exists(stripe.Address) Then d1.Remove (stripe.Address)
- Set stripe = Union(.Parent.Range(prev), stripe)
- d1.Remove prev
- d1(stripe.Address) = stripe.Count
- Set stripeOffset = Union(stripeOffset, .Parent.Range(prev))
- bCombine = True
- End If
- Next prev
- If Not bCombine Then d1(stripe.Address) = stripe.Count
- Next stripe
- End If
- Next lCol
- .Replace What:="", Replacement:="0"
- End With
-
- Set d2 = CreateObject("scripting.dictionary")
- For Each x In d1.items
- If d2.exists(x) Then
- d2(x) = d2(x) + 1
- Else
- d2(x) = 1
- End If
- Next
- For Each x In d2.keys
- Debug.Print "±¿n " & x & " : " & d2(x) & "Ó"
- Next
- End Sub
½Æ»s¥N½X |
|