作者home0303 (Blue night)
看板Office
標題[算表] Excel VBA陣列寫法求教
時間Fri Jan 21 08:31:02 2022
軟體:EXCEL
版本:2010
Sub 這筆第幾次出現() '220121當COUNTIF法跑不動時的替代方式
Application.ScreenUpdating = 0
For i = 1 To 1048575
If Cells(1 + i, 3 - 1) = "" Then Exit Sub
If Cells(1 + i, 3 - 1) <> Cells(1 + i - 1, 3 - 1) Then
Cells(1 + i, 3) = 1
Else
Cells(1 + i, 3) = Cells(1 + i - 1, 3) + 1
End If
Next
Application.ScreenUpdating = 1
End Sub
想請教,如何使用陣列arr的方式改寫上述程式,使執行效率提升。
謝謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.136.168.168 (臺灣)
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Office/M.1642725064.A.DA6.html
3F:→ home0303: 謝謝W大 我研究看看 01/21 09:50