Results 1 to 8 of 8

convert formulas to vba - countif and find unique values

Threaded View

  1. #1
    Registered User
    Join Date
    07-16-2004
    Location
    Hampshire, England
    MS-Off Ver
    2007
    Posts
    29

    convert formulas to vba - countif and find unique values

    Hi

    I have a workbook (sample attached) that contains 2 worksheets (Data and Stats) with info re people selecting boxes.

    In the Data worksheet I paste the collected data into columns D:G (columns A:C then calculate the month, day and time).

    In the Stats worksheet I have 2 columns; column A which contains the Box Reference number and column B which contains the Box Name (box1, box2 etc).

    I currently have a formula, in column C of the Stats worksheet, that calculates the number of times each box is selected as follows:

    = COUNTIF(Data!$G$2:INDEX(Data!$G:$G,$R$2),$A2)
    I have another formula, in column D of the Stats worksheet, that calculates the number of unique selections of a box by a single person ie if Box2 is selected by Person1 on more than one occasion then that is counted as 1 unique selection. Code as follows:

    =SUM(IF(FREQUENCY(IF((Data!$G$2:INDEX(Data!$G:$G,Data!$R$2)=$A2),MATCH(Data!$F$2:INDEX(Data!$F:$F,Data!$R$2),Data!$F$2:INDEX(Data!$F:$F,Data!$R$2),0),""),IF((Data!$G$2:INDEX(Data!$G:$G,Data!$R$2)=$A2),MATCH(Data!$F$2:INDEX(Data!$F:$F,Data!$R$2),Data!$F$2:INDEX(Data!$F:$F,Data!$R$2),0),""))>0,1))
    This all works perfectly, but I frequently have up to 30,000 rows in the Data worksheet and the calculation can take up to 30 minutes! What I would like to do is convert these formulas to a macro, which I assume will speed up the calculation time?

    Any help would be appreciated....

    Thanks
    Attached Files Attached Files

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