Results 1 to 3 of 3

Use array to speed up UDF calculations

Threaded View

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    5

    Use array to speed up UDF calculations

    Hi

    I am quit new with working with VBA.

    I have a lot of UDF in my sreadsheet and it is working very slow.

    Therefore I am looking for a way to read inn all the input data in an array, calculate the functions
    in vba and then print the results back to another spreadsheet. I guess this would be much faster,but
    I have trouble understanding arrays....

    This is the code I have come up with so far, but it is not working at all rather than printing some text back to the spreadsheet.

    Public Sub main()
    
    For k = 2 To 20000 ' 2000 is max
      u = Readmembers(k)
                
                Readmembers (k)
                                    
                Printresults (k)
                                    
    Next k
    
    End sub
    
    Public Function Readmembers(j)
    
    'read data for use in the UDF Testfunction
    
    x = Worksheets("input_UDF").Cells(j, 1)
    b = Worksheets("input_UDF").Cells(j, 2)
    s = Worksheets("input_UDF").Cells(j, 3)
    
    
    End Function
    
    
    Public Sub Printresults(j)
    
    Worksheets("Print result").Cells(j, 1) = "Testfunction" ' The result from the fuction here
    
    End Sub
    
    
    Function Testfunction(x, b, s)
    
    Testfunction = x * b * s
    
    
    End Function
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. Well, you're not new, but you only have 2 posts. --6StringJazzer




    Thanks for any help.
    Attached Files Attached Files
    Last edited by 6StringJazzer; 06-19-2015 at 09:05 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 06-21-2014, 03:11 PM
  2. Speed up VBA with 2.5 billion calculations
    By bubleeshaark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-09-2013, 11:34 PM
  3. Speed Up calculations - sumproduct
    By Risels7 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-03-2013, 11:51 PM
  4. Speed up spreadsheet calculations
    By mcinnes01 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-23-2010, 11:20 AM
  5. Speed calculations
    By ABSTRAKTUS in forum Excel General
    Replies: 3
    Last Post: 05-21-2010, 05:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1