EXCEL VBA.從〔7個號碼〕中任取〔6個〕為組合,列出等差類別
<.准提部林.>
---------------------------------
範例檔簡介:
■主要需求:
從每列〔7個號碼〕中任取〔6個〕分為7種組合,
再依其〔相連〕或〔不相連〕數字間的〔差值〕做統計,
以〔最高〕〔相同等差〕者為其〔類別〕。
■等差值表:為7個號碼〔相連〕〔不相連〕之間的差值參考表。
J4公式:右拉下刷
=SMALL($A4:$G4,MID("234567345674567567677",COLUMN(A2),1))-
SMALL($A4:$G4,MID("123456123451234123121",COLUMN(A2),1))
■程式碼:此段先將7個號碼拆分6碼7組再判斷類別,
類別的判斷程式碼請參考範例檔。
Sub 等差列表7取6()
Dim vNum&(1 To 7), vRow&, vRR$(), vTT
Dim x1&, x2&, x3&, x4&, x5&, x6&, Xm&
[I4:I6000].ClearContents
vRow = [a65536].End(xlUp).Row - 3
If vRow <= 0 Then Exit Sub
ReDim vRR(1 To vRow, 0)
vTT = Array("6m", "5m", "4m2m", "4m", "3m3m", _
"3m2m", "3m", "2m2m2m", "2m2m", "0m")
'--------------------
For k = 1 To vRow
mGetNo = 9
For i = 1 To 7
vNum(i) = Application.Small(Range("A" & k + 3).Resize(1, 7), i)
Next i
'--------------------
For x1 = 1 To 2: vMM(1) = vNum(x1)
For x2 = x1 + 1 To 3: vMM(2) = vNum(x2)
For x3 = x2 + 1 To 4: vMM(3) = vNum(x3)
For x4 = x3 + 1 To 5: vMM(4) = vNum(x4)
For x5 = x4 + 1 To 6: vMM(5) = vNum(x5)
For x6 = x5 + 1 To 7: vMM(6) = vNum(x6)
Call 等差統計
If mGetNo > mChk Then mGetNo = mChk
Next: Next: Next: Next: Next: Next
vRR(k, 0) = vTT(mGetNo)
Next k
'--------------------
Range("I4").Resize(vRow) = vRR()
Erase vRR(), vNum(), vMM(): vTT = ""
Beep
End Sub
---------------------------------
<範例檔>:
LV超3A名牌購物網
- May 06 Sun 2012 16:36
VBA~等差分類程式語法編輯和函數等差明細表。
close
LV超3A名牌購物網
全站熱搜
留言列表