+ Reply to Thread
Results 1 to 19 of 19

How to make faster. Using Worksheetfunction.Countifs

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    How to make faster. Using Worksheetfunction.Countifs

    I have this code (see below). Is there a way to make this faster or is there a Better way to do this? If not thats ok.......just wondering.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How to make faster. Using Worksheetfunction.Countifs

    Please Login or Register  to view this content.



  3. #3
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: How to make faster. Using Worksheetfunction.Countifs

    The alternative, it may better for you, plz test it because of I have no sample file to test
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    i will check them out . I will probably have questions............

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    I am trying to check the suggestions out.....running into issues. Can get code to compile.

    I created a test file to make it easier to see what i am trying to do. Sorry for not doing this earlier.

    THe original file i tried to upload had 96K rows......had to shorten to meet the max file size requirements.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    i just realized that when i made the file smaller to get it to post here i changed the name which caused an error in addition to the error i was asking about. so i have corrected the name issue but i still get "application-defined object defined error".
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    here is the code which is causing the error


    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    still cant figure out the error............

    any ideas what this is doing


    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-10-2011
    Location
    hanoi
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: How to make faster. Using Worksheetfunction.Countifs

    It is a very nice thing to see your excellent work and I like your article very much. With your rich knowledge, we can learn more from your wonderful post. Thanks so much.

  10. #10
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    tigertiger and snb,

    I tried both of your suggestions and

    snb: I cant get yours to compile

    tigertiger: Yours gives a run time error.

    Anyideas?

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to make faster. Using Worksheetfunction.Countifs

    The most obvious thing is that this:
    Please Login or Register  to view this content.
    should be:
    Please Login or Register  to view this content.
    since that's not a variable, it's the actual sheet name. Personally I think a pivot table would be simpler.
    Remember what the dormouse said
    Feed your head

  12. #12
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    romperstomper thanks for replying.

    In the file i sent out, the entire code is shown in the file.

    In the file i define

    Sheet_DCF_Inputfile="Sheet_DCF_Inputfile"

    this should work.........right?

    if you have time i would like to understand the approach of tigertiger but also if you have alternative approach i would like to understan that as well.

  13. #13
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to make faster. Using Worksheetfunction.Countifs

    Tigertiger's code won't work since it's trying to use R1C1 referencing in the Range call.
    Ironically, to figure out why snb's code wasn't working for you, Option Explicit would have helped you.

    Try this implementation of snb's code:
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    thanks.

    I will check out the code you sent in just a bit. Can tigertigers code be changed from r1c1 to someother type to make it work? thanks.

  15. #15
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to make faster. Using Worksheetfunction.Countifs

    It could be but it still wouldn't work unless it was basically converted back to your original version.

  16. #16
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    romperstomper,

    oh really. For some reason i was thinking that tigertiger's soln did not require a for loop and if it did not then it looked like it would go faster. Again, i did not understand tigertiger's code but i was trying to. From what i could tell it looked like tigertiger was trying to insert formulas thoughout a range.

    Just curious then how tigertiger's code would be faster than mine if its nearly the same as mine. Are there somethings in my code which could be made faster?

  17. #17
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to make faster. Using Worksheetfunction.Countifs

    I'm not really sure why you are asking me to explain the thinking behind someone else's code?
    It appears to be trying to return the result of one countifs formula to an entire range, and that won't work. On the other hand he/she did say it was untested.

  18. #18
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to make faster. Using Worksheetfunction.Countifs

    romperstomper, your so right. i appologize.

    thanks for your helpl!

  19. #19
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: How to make faster. Using Worksheetfunction.Countifs

    Quote Originally Posted by welchs101 View Post
    romperstomper,
    Just curious then how tigertiger's code would be faster than mine if its nearly the same as mine. Are there somethings in my code which could be made faster?
    Sorry for several days, in that I haven't surfed the forum and seen the topic (for a long time) as well, so I think that the topic is solved. why don't you send me a private message

    The code you need, like that (and attached file, I 've done)

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by tigertiger; 07-14-2011 at 06:06 AM.

+ 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