Is it possible to fill an array with row numbers which match a certain criteria without looping?

前端 未结 8 1793
陌清茗
陌清茗 2020-11-27 17:33

I would like to fill an array in VBA with the row numbers of only rows which meet a certain criteria. I would like the fastest method possible (for example, something like <

8条回答
  •  自闭症患者
    2020-11-27 18:14

    Still around 2-3 times the time of the efficient variant array from Chris, but the technique is powerful and has application beyond this question

    One point to note is that Application.Transpose is limited to 65536 cells, so a longer range needs to be "chunked" into pieces.

    Sub GetEm()
    Dim x
    x = Filter(Application.Transpose(Application.Evaluate("=IF(A1:A50000=""aa"",ROW(A1:a50000),""x"")")), "x", False)
    End Sub
    

提交回复
热议问题