- ©«¤l
- 185
- ¥DÃD
- 47
- ºëµØ
- 0
- ¿n¤À
- 227
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN 7
- ³nÅ骩¥»
- ºX舰ª©
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-9-14
- ³Ì«áµn¿ý
- 2024-11-19
|
- Option Explicit
- Sub pºâ®M¸Ë¯Å§O()
- Dim ws As Worksheet
- Set ws = ThisWorkbook.ActiveSheet
-
- Dim lastRow As Long
- lastRow = ws.Cells(ws.Rows.Count, "L").End(xlUp).Row
-
- Dim i As Long
- Dim score As String
- Dim skip As Boolean
- Dim combinations As Variant
- Dim scores As Variant
-
- ' ©w¸q®M¸Ë©M¯Å§O
- combinations = Array("¨}ÀuÀu¨}", "Àu¨}¨}Àu", "¨}ÀuÀuÀu", "Àu¨}¨}¨}", "¨}Àu¨}", "Àu¨}Àu", "ÀuÀu", "¨}¨}")
- scores = Array("2", "2", "3", "3", "3", "3", "3", "3")
-
- For i = 2 To lastRow
- If Not skip Then ' ¦pªGskip¬°False¡A«h°õ¦æ¦¹¥N½X¶ô
- Dim j As Long
- 'Àˬd·í«eªº¦r²Å§Ç¦C¡]combo¡^¬O§_»Pcombinations¼Æ²Õ¤¤ªº¥ô¦ó¤@Ó¤¸¯À¤Ç°t¡C
- '¦pªG¤Ç°t¡A«h®Ú¾Ú¹ïÀ³ªºscores¼Æ²Õ¤¤ªº¯Å§O¨Ó§ó·sscoreÅܶq¡A¨Ã¦b¤u§@ªíªº"O"¦C¤¤Åã¥Ü¸Ó¯Å§O¡C
- For j = LBound(combinations) To UBound(combinations)
- Dim combo As String
- combo = ""
- On Error Resume Next
- combo = ws.Cells(i, "L").Value & ws.Cells(i + 1, "L").Value & ws.Cells(i + 2, "L").Value & ws.Cells(i + 3, "L").Value
- On Error GoTo 0
- '³o¬q¥N½Xªº¥Øªº¬O¦b§ä¨ì¤Ç°tªº®M¸Ë®Épºâ¨ÃÅã¥Ü¬ÛÀ³ªº¯Å§O¡C
- combo = Left(combo, Len(combinations(j))) ' ¨ú²Õ¦Xªºªø«×,³o¦æ¥N½X±Ncombo¦r²Å¦êªº¥ª°¼³¡¤À¡]ªø«×¬°combinations(j)ªºªø«×¡^½áȵ¹combo¡C
- ' ³o¬O¬°¤F½T«Ocomboªºªø«×»P·í«eªº®M¸Ëcombinations(j)ªºªø«×¬Û¦P¡A¥H«K¶i¦æ¤ñ¸û¡C
- If combo = combinations(j) And ws.Cells(i, "L").Value <> ws.Cells(i - 1, "L").Value Then 'Àˬdcombo¬O§_µ¥©ó·í«eªº®M¸Ëcombinations(j)¡A¨Ã¥B·í«e¦æªº"L"¦CªºÈ»P«e¤@¦æªº"L"¦CªºÈ¤£¦P
- score = scores(j)
- ws.Cells(i + Len(combinations(j)) - 1, "O").Value = score ' ¦bO¦Cªº¬Û¹ï¦æ¼ÆÅã¥Ü¯Å§O
- If score = 2 Or score = 3 Then
- skip = True ' ¦pªGskip¬°True¡A«h°õ¦æ¦¹¥N½X¶ô
- End If
- Exit For
- End If
- Next j
- Else
- '¥H¤U³o¬q¥N½Xªº¥Øªº¬O¦b¹J¨ì·sªº¦r²Å§Ç¦C¶}©l®É¡]§Y·í«e¦æªº"L"¦CªºÈ»P«e¤@¦æªº"L"¦CªºÈ¤£¦P¡A¨Ã¥B·í«e¦æªº"L"¦CªºÈµ¥©ó·í«e®M¸Ëªº²Ä¤@Ó¦r²Å®É¡^¡A°±¤î¸õ¹L¡¥N¡C
- '¦pªGskip¬°True¡A«h·|¸õ¹L·í«eªº¡¥N¡Aª½¨ì¹J¨ì·sªº¦r²Å§Ç¦C¶}©l¡C³o¼Ë¥i¥H¨¾¤î¦b¦P¤@Ó¦r²Å§Ç¦C¤¤¦h¦¸pºâ¯Å§O¡C
- If ws.Cells(i, "L").Value <> ws.Cells(i - 1, "L").Value And ws.Cells(i, "L").Value = Left(combinations(j), 1) Then
- skip = False
- End If
- End If
- Next i
- End Sub
½Æ»s¥N½X |
|