EXCEL VBA.〔多條件.複合式〕資料之〔篩選及分表〕.續2
<.准提部林.>
---------------------------------
<續前題>
VBA~頭尾數、連號依據選項條件剔除的語法。
範例檔簡介:
■新增需求:
<需求F.複合式等差>
.比對同列6個數字〔相連〕或〔不相連〕之間的〔相同差數〕。
.設置10個選項(可複選),以供〔篩選及分表〕之條件。
■程式碼:僅列出部份判斷式,詳細〔等差組合表〕請參考範例檔。
Sub 等差統計()
Dim vA$, vB$, j&, k&, x&, y&, M&(1 To 14)
vA = "234563456456566"
vB = "123451234123121"
ReDim vRR(1 To vRow, 0)
For k = 1 To vRow
For x = 1 To 14
M(x) = vMM(k, Mid(vA, x, 1)) - vMM(k, Mid(vB, x, 1))
Next x
'<6等差>
If M(1) = M(2) And M(2) = M(3) And M(3) = M(4) And M(4) = M(5) Then _
vRR(k, 0) = "6m": GoTo NEXT01
'<5等差>
If M(1) = M(2) And M(2) = M(3) And M(3) = M(4) Then vRR(k, 0) = "5m": GoTo NEXT01
'<4+2等差>
If M(1) = M(2) And M(2) = M(3) And M(3) = M(5) Then vRR(k, 0) = "4m2m": GoTo NEXT01
'<4等差>
If M(1) = M(2) And M(2) = M(3) Then vRR(k, 0) = "4m": GoTo NEXT01
'<3+3等差>
If M(1) = M(2) And M(4) = M(5) Then vRR(k, 0) = "3m3m": GoTo NEXT01
'<3+2等差>
If M(1) = M(2) And M(2) = M(4) Then vRR(k, 0) = "3m2m": GoTo NEXT01
'<3等差>
If M(1) = M(2) Or M(2) = M(3) Or M(3) = M(4) Then vRR(k, 0) = "3m": GoTo NEXT01
'<2+2+2等差>
If M(1) = M(3) And M(3) = M(5) Then vRR(k, 0) = "2m2m2m": GoTo NEXT01
'<2+2等差>
If M(1) = M(3) Or M(1) = M(4) Or M(1) = M(5) Then vRR(k, 0) = "2m2m": GoTo NEXT01
'<無等差>
vRR(k, 0) = "0m"
NEXT01:
Next k
End Sub
---------------------------------
<範例檔>:
LV超3A名牌購物網
留言列表