Excel CountA、CountIf,二者的比較

如果先把資料整理好,有順序的話,那麼使用countA,會快很多

    '統計機率
        Dim i As Integer, j As Integer
        lLastRow = ShtXy.Range("A" & Cells.Rows.Count).End(xlUp).Row
        Set myTbl = ShtXy.Range("A" & lLastRow).CurrentRegion
        For j = 1 To All_Ball
            If j < 10 Then
                chkBall = "0" & j
            Else
                chkBall = j
            End If
            Per_x = Application.CountA(myTbl.Columns(j + 2))    '改這樣變更快,資源佔用少
           'Per_x = Application.CountIf(myTbl, chkBall)         '舊程式
            With ShtTmp
                i = 1
                .Cells(j + 2, i + 1) = Per_x                '次數
                .Cells(j + 2, i + 2) = chkBall              '球號
                .Cells(j + 2, i + 3) = arrShowBallCon(j)    '落號距離
            End With
        Next

留言

這個網誌中的熱門文章

歐姆龍 HEM-7600T 評價,購買心得分享(打臉文)

超任 三國志3代,登入武將金手指

年青人眼鏡評價(負評),辛酸血淚史分享文