+ Reply to Thread
Results 1 to 3 of 3

Optimizing WorksheetFunction.CountIf

  1. #1
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Optimizing WorksheetFunction.CountIf

    Hellos!

    I'm currently using WorksheetFunction.CountIf to determine if each cell in a range has a matching value in another range.

    In my limited VB knowledge, I went with this function because I am unfamiliar with any other options. In terms of processing, would there be a smarter solution?

    (I'll post a workbook sample as soon as the current macro completes; running on 12 minutes so far.)

    The code I've written so far:

    Please Login or Register  to view this content.

    It's just writing the word Exclude out in column AR when G matches a record on my Exclusions list. Is there a smart way to write this?

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Optimizing WorksheetFunction.CountIf

    Does it have to be a macro? Sounds like a vlookup might suit.

    at least I don't think it would take 12+ minutes.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Optimizing WorksheetFunction.CountIf

    Unfortunately it does. I'm using Excel as a database for filtering records, because the trigonometric formulas I'm applying don't play nice with Access.

    This macro is just adding an extra column of information to 294,379 rows of data, with the intention of preventing an actual formula from being left in the adjacent cells. Pasting Values over top of that many formulas has crashed my Excel 3 times so far, so I went this route instead.

    The end result takes the latitude and longitude of each row, and compares it to the entry of another single point, and then copies each record to a new sheet if it's less than 50 miles away, and if column column AA = something, and if AB > 0 or if AG = Exclusion, and if column Z does not contain two possible strings.

    Good stuff.

    It looks something like this:

    Please Login or Register  to view this content.
    Ultimately I'm building a data set for some blackbelts to play with, and they need everything to be clean of any formulas or anything volatile that would increase process and handling time when dealing with 300k rows.

    Edit: I brought down the ranges to 50k rows at a time, stopped screen updating, and included a diagnostics tab to timestamp before and after so I can measure my runtime. 6 x 9 minutes a pop. I guess I just wanted to know if there were other options, such as Search, Find, etc.
    Last edited by daffodil11; 02-25-2014 at 05:11 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Optimizing VBA
    By walduxas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2012, 02:28 PM
  2. Application.WorksheetFunction.CountIF
    By krsna83_pp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2011, 08:27 AM
  3. Unable to get countIF property of worksheetFunction class
    By Deamo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-10-2010, 09:35 PM
  4. Error using WorksheetFunction.Countif
    By Kris_Wright_77 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2006, 10:45 AM
  5. WorksheetFunction.CountIf
    By hotherps in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2005, 11:31 AM

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