Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Couple of general tips.</p> <ol> <li><p>Take your function and work out where the bottlenecks really are. See this question for the <a href="https://stackoverflow.com/questions/1190833/what-are-the-best-tools-for-optimizing-queries-in-vba-and-why">use of timer</a> in excel. I'm sure there are VBA profilers out there... but you probably don't need to go that far. <em>(NB: do this with one cell of data first...)</em></p></li> <li><p>Think about your design... 400x120 cells of data is <strong>not</strong> a lot. And for it to take hours that must be painful. (<em>In the past i've cracked it after waiting a minute for 1,000s of <code>VLOOKUPS()</code> to return</em>) anyway maybe instead of having having a stack of UDFs why not have a simple subroutine that <code>for..each</code> through the range and does what you need it to do. 48,000 cells could take seconds or maybe just minutes. You could then associate the subroutine with a button or menu item for the user. </p></li> </ol> <p>Out of interest i had a quick look at option 2 and created MyUDF(), using the sub <code>DoMyUDF()</code> to call it for the active selection worked 10x faster for me, than having the UDF in each and every cell.</p> <pre><code>Option Explicit Function MyUDF(myVar As Variant) As Variant MyUDF = myVar * 10 End Function Sub DoMyUDF() Dim r As Range Dim c As Variant Dim t As Single t = Timer If TypeName(Selection) &lt;&gt; "Range" Then Exit Sub End If Set r = Selection.Cells Application.DisplayStatusBar = True For Each c In r c.Value = MyUDF(c.Value) Application.StatusBar = "DoMyUDF(): " &amp; Format(Timer - t, "#0.0000ms") Next Debug.Print "DoMyUDF(): " &amp; Format(Timer - t, "#0.0000ms") End Sub </code></pre> <p>If you replace <code>MyUDF()</code> with your UDF this may only save you 4.5 minutes... but it's possible there are some other economies you can build in. Especially if you are repeating the same calcs over and over again.</p>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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