+ Reply to Thread
Results 1 to 3 of 3

Streamlining VBA code to help faster processing

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    Ougadougou, Burkina Faso
    MS-Off Ver
    Excel 2003
    Posts
    27

    Streamlining VBA code to help faster processing

    Hi guys,

    I am using the following VBA code in one of my excel workbooks:

    Please Login or Register  to view this content.
    This code calculates the median of entries in column C based on values in columns A and B and puts the median in column D.
    I want to modify this code to implement an additional functionality. Since there is a repetition of data in my worksheet, I want the code to compare the current cell with all the previous cells and skip the median calculation if it has already been done. Any ideas on how to do this?

    Thanks.
    Last edited by rylo; 07-17-2009 at 12:49 AM. Reason: added code tags

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Streamlining VBA code to help faster processing

    Assuming (from before) that the data is unsorted the quickest approach is to concatenate the two columns of interest enabling you to conduct a quick COUNTIF test against the concatenation column... else you will need to use an approach along the lines of:

    =IF(ISNUMBER(LOOKUP(2,1/((rangeA=valueA)*(rangeB=valueB)))),MEDIAN(IF(...)),"")

    This will still be quicker than conducting all of the arrays you're presently conducting but not as fast as it could be... you could if preferred even ensure you only insert formulae into the relevant cells... ie:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-14-2009
    Location
    Ougadougou, Burkina Faso
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Streamlining VBA code to help faster processing

    Thanks a lot DO. The code worked just fine. It is still a little slow but I guess this is the best solution I have right now. Thanks again for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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