Note that there are some explanatory texts on larger screens.

plurals
  1. POOptimize Excel Formula that uses large arrays
    primarykey
    data
    text
    <p>I have used the below mentioned excel formula.</p> <pre><code>=INDEX(TABL,SMALL(IF(COUNTIF(H2,$A$1:$A$325779)*COUNTIF(I2,"&lt;="&amp;$B$1:$B$325779),ROW(TABL)-MIN(ROW(TABL))+1),1),3) </code></pre> <p>Where "TABL",a table, is A1:E325779 and is the source of my lookup array.</p> <p>The formula mentioned is the exact requirement but is taking a lot of time to update the excel for 400,000+ cells containing this formula.</p> <p>Can this be optimized? Or can this be equated to a faster macro?</p> <p>Its taking 1 second to update 1 cell!!! That's a very long time to update all 400K+ cells once!!!</p> <p>Screenshot of a sample worksheet is as below.</p> <p><img src="https://i.stack.imgur.com/1g5Ka.png" alt="enter image description here"></p> <p>I have based my program on Martin Carlsson's. it is processing 100 records in 30 seconds. can it be improved?</p> <pre><code>Sub subFindValue() Application.ScreenUpdating = False Application.DisplayStatusBar = False Application.Calculation = xlCalculationManual Application.EnableEvents = False Cells(2, 12) = Format(DateTime.Now, "yyyy-MM-dd hh:mm:ss") Dim varRow As Variant Dim varRowMain As Variant Dim lookupTable As Variant Dim lookupValueTable As Variant lookupValueTable = Range("G2:J309011").Value lookupTable = Range("A2:D325779").Value varRowMain = 1 varRow = 1 Do Until varRowMain = 309011 Do Until varRow = 325779 If lookupTable(varRow, 1) = lookupValueTable(varRowMain, 1) And lookupTable(varRow, 2) &gt;= lookupValueTable(varRowMain, 2) Then lookupValueTable(varRowMain, 3) = lookupTable(varRow, 3) lookupValueTable(varRowMain, 4) = lookupTable(varRow, 4) Exit Do End If varRow = varRow + 1 Loop If IsEmpty(lookupValueTable(varRowMain, 3)) Then lookupValueTable(varRowMain, 3) = "NA_OX" lookupValueTable(varRowMain, 4) = "NA_OY" End If varRowMain = varRowMain + 1 varRow = 1 Loop Range("G2:J309011").Value = lookupValueTable Cells(3, 12) = Format(DateTime.Now, "yyyy-MM-dd hh:mm:ss") Application.ScreenUpdating = True Application.DisplayStatusBar = True Application.Calculation = xlCalculationAutomatic Application.EnableEvents = True End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload