Excel FindNext,也可以這樣玩
function 使用after
'初始值
Dim intStar_Rng As Integer, Str_ShtBase As String,All_Ball as integer
All_Ball =39
intStar_Rng = 6
Str_ShtBase = "基本分佈圖"
strBall = Fn1_取得球號字串(All_Ball)
'變數設定
Dim ShtBaseImg As Object
Set ShtBaseImg = Sheets(Str_ShtBase)
'
With ShtBaseImg
lLastRow = .Range("A" & Cells.Rows.Count).End(xlUp).Row
Set Rng = .Cells(7, 3).Resize(lLastRow - intStar_Rng, All_Ball)
'Debug.Print Rng.Columns(1).Address
For j = 1 To All_Ball
Result = Application.CountA(Rng.Columns(j))
Dim arrTab
ReDim arrTab(1 To Result)
For i = 1 To Result
If i = 1 Then
Set S_Rng = Rng.Cells(1, 1)
Else
Set S_Rng = tmpRng
End If
Set tmpRng = Rng.Find(what:=strBall(j), after:=S_Rng, LookAt:=xlWhole)
arrTab(i) = tmpRng.Row
Debug.Print tmpRng.Row
Next i
.Cells(6, 2 + 39 + 10 + 5).Resize(1, Result) = arrTab
Next j
End With
end function
留言
張貼留言