+ Reply to Thread
Results 1 to 20 of 20

Countif with ADO or ScriptingDictionary

  1. #1
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Countif with ADO or ScriptingDictionary

    I have 2 sheets Sheet1 and Sheet2.
    In Sheet1 There is a table which Column "C" has Item Numbers.(Approx. 60.000 Rows)
    In Sheet2 There is a table which Column "C" has Item Numbers.(Approx. 50.000 Rows)

    Starting from Sheet1 C2 cell to end of C Column (as C59850) ;
    I'd like to count Item Numbers in Sheet2, to find how many Item Numbers exist in Sheet2 and put counting values to Column "V" for each.

    In order to find the result for each Item Number in Sheet1, I used below code.
    Please Login or Register  to view this content.

    But Excel gives "Not Responding" message and crash.

    I want to use ADODB or ScriptingDictionary method instead of my code.

    If there is a solution with ADO or ScriptingDictionary , I thank in advance for any reply and help.
    Best regards.
    Last edited by turist; 12-20-2018 at 04:56 PM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    Try
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    Dear jindon,
    Thanks a lot for your reply.
    Some Items counted more than 1 in Sheet1, but Code only shows "1" value as counted.
    How can I modify the code in order to get , if counts more than "1" ?

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    Tested befote I posted.
    So, need to see your workbook.

    I'll be busy for the day, so I can not reply soon.

  5. #5
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    Quote Originally Posted by jindon View Post
    Tested befote I posted.
    So, need to see your workbook.

    I'll be busy for the day, so I can not reply soon.
    Dear jindon
    I attached My Workbook.
    Waiting for reply.
    Thanks and regards
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    OK, I'm back.

    Your question is now something more than you stated originally, so I need to see your EXACT results.

    Post a workbook showing before/after with a much less rows of data that you can describe the logic enough, so that I can wrote a code.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    This is what I read from your workbook.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    Dear jindon again I attached workbook and explained the results and differences on Sheet1.
    Could you please look and help to solve it.

    Thanks in advance for your kind support again.

    Best regards.
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    Loop through Col.C in Sheet1 and if the same value exists in Sheet2, count same value in SHEET1!C:C then result in col.V and pull data from col.L in the same row in Sheet2 to Sheet1 col.U

    This is how I read your problem.
    If I'm correct, your results are wrong.

    Regarding 4003537517, you have 2.
    one in C37779 and other in C42716, 1st one have blank in col.L, but 2nd one have 1 in col.L.
    My code is taking the last one if there are multiple value in Col.C in Sheet2.
    Last edited by jindon; 12-21-2018 at 10:32 AM.

  10. #10
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    Dear jindon.
    I am sorry for taking your time.

    My aim:
    1-Loop through Col.C in Sheet1 COUNT in Sheet2 Col.C and pull counting numbers to Col.V in Sheet1
    Regarding 4003537517 there are 2
    Col V. Sheet1 should show "2"

    2-Loop through Col.C in Sheet1 COUNT in Sheet2 Col.C and pull Col.L value to Col.U in Sheet1 (if Count number is >1 then pull LAST value in Col.L)
    İn this case Col. L value can be "blank" and Col.U in Sheet1 will be "blank". Shortly , whatever is exist in Col.L in Sheet2 will be in Col.U Sheet1
    Regarding 4003537517, you have 2.
    one in C37779 and other in C42716, 1st one have blank in col.L, but 2nd one have 1 in col.L.
    My code is taking the last one if there are multiple value in Col.C in Sheet2.
    This is CORRECT.


    I would be grateful if you can modify the code according to above explanation.

    Thanks a lot for your support, help and sensibility.
    Best regards.
    Best regards
    Last edited by turist; 12-21-2018 at 03:13 PM.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    So, my logic in counting was correct, therefore your result was something wrong, because it can't be 2 when use =COUNTIF(C:C,C43475).

    Pulls the data in col.L from sheet2 when multiple ITEM NO found in sheet2.
    Change one line
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    Dear jindon,
    Please use this formula in Sheet1 on Cell V43475

    =COUNTIF(Sheet2!C:C;Sheet1!C43475)

    What do you see ?

    This formula's result is =2 Completely CORRECT.


    I'm looking for this logic in the code.

    Thanks for your kind help.
    Last edited by turist; 12-22-2018 at 12:32 AM.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    Count Col.C in Sheet2, not Sheet1...
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    Dear Jindon,
    Finally I reached the correct result , thanks.
    I tried to combine two macros as below.
    Please Login or Register  to view this content.
    Now, I need to shorten this modification.

    Could you make a favour for me to redesign it.

    Thanks for your patient support and help.
    Best regards.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    Doesn't make sense to me,

    First part picks data from first appeared row from Col.L in Sheet2 and 2nd from the last appeared and overwrites Col(21).

    What are you trying to do?

  16. #16
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    Thanks Jindon.
    May be ı can not tell what I need.
    You don't have to reply any more.
    Thank you very much indeed.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    As I said already, upload a workbook with much less data set showing before/after, so that better understanding your problem, otherwise no way.

    Anyway,
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  18. #18
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    Dear jindon
    Please look at my attached workbook.
    Thanks again.
    Best regards
    Attached Files Attached Files

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Countif with ADO or ScriptingDictionary

    Change to
    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Countif with ADO or ScriptingDictionary

    That's it,happy end.
    Thank you very much.
    Best regards.

+ 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. Adding a COUNTIF function to an existing IF AND COUNTIF Formula...
    By Ourkid123uk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-24-2018, 10:09 AM
  2. Replies: 8
    Last Post: 05-27-2017, 07:04 AM
  3. Faster if/countif formula for flagging uniques - countif too slow
    By Speshul in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-19-2015, 01:44 PM
  4. Combining a Date Range COUNTIF and a general COUNTIF
    By jacobtom in forum Excel General
    Replies: 1
    Last Post: 09-15-2011, 05:06 PM
  5. Adding a CountIF to a formula that is already Countif
    By Cmorgan in forum Excel General
    Replies: 4
    Last Post: 06-01-2011, 09:34 AM
  6. [SOLVED] COUNTIF or not to COUNTIF on a range in another sheet
    By Ellie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-15-2005, 05:06 PM
  7. Countif w/ Multiple Criteria-How do I use countif
    By Patrick_KC in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-09-2005, 05:05 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