½Ð±Ð¦U¦ì«e½úvba Ãö©ó³æ¤@Àx¦s®æ¦¡¤º²Îp°ÝÃD~
- ©«¤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
|
¥»©«³Ì«á¥Ñ stillfish00 ©ó 2014-5-26 19:59 ½s¿è
¦^´_ 1# ii31sakura
¶È¨Ñ°Ñ¦Ò
³Ì¦nªº°µªkÁÙ¬O¤@¶}©lªºªí®æ´N¥ý©w¸q©ú½T¡A³æ¤@Àx¦s®æ¤£n¦h¥Î³~¡C- Sub Test()
- Dim d, i As Long, dteDate As Date, lValue As Long, sType As String
- Dim oReg, oMatch, x, y, lCnt As Long, ar
-
- Set d = CreateObject("scripting.dictionary")
- Set oReg = CreateObject("vbscript.regexp")
- With oReg
- .Global = True
- .Pattern = "(\d+)-(\S+)"
- End With
-
- 'Analyze
- With Sheets("Sheet1").[A1].CurrentRegion
- If .Rows.Count < 2 Then Exit Sub
- For i = 2 To .Rows.Count
- dteDate = .Cells(i, 1).Value
- 'make 2 levels dictionary
- If Not d.exists(dteDate) Then Set d(dteDate) = CreateObject("scripting.dictionary")
-
- Set oMatch = oReg.Execute(.Cells(i, 2).Value)
- For Each x In oMatch
- lValue = CLng(oReg.Replace(x.Value, "$1"))
- sType = oReg.Replace(x.Value, "$2")
- With d(dteDate)
- If .exists(sType) Then
- .Item(sType) = .Item(sType) + lValue
- Else
- .Item(sType) = lValue
- lCnt = lCnt + 1
- End If
- End With
- Next
- Next
- End With
-
- 'Read to array
- ReDim ar(1 To lCnt, 1 To 3)
- i = 0
- For Each x In d.keys
- For Each y In d(x).keys
- i = i + 1
- ar(i, 1) = x
- ar(i, 2) = y
- ar(i, 3) = d(x)(y)
- Next
- Next
- 'Fill into worksheet
- With Sheets("Sheet1").[F1]
- .Resize(1, 3).Value = Array("¤é´Á", "¨ä¥¦¶µ¥Ø", "¨ä¥¦Á`¼Æ¶q(Áû²É¼Æ)")
- .Offset(1).Resize(lCnt, 3).Value = ar
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|