+ Reply to Thread
Results 1 to 32 of 32

VBA Countif -Out of range

  1. #1
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    VBA Countif -Out of range

    Dear Expert.

    I having an issue for Countif function. Below code showed out of range.
    Please Login or Register  to view this content.
    The file in was saved in same folder. Any idea?

    Thank you

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

    Re: VBA Countif -Out of range

    Is Workbooks("Dean-Temp-PC2.xlsm") open?

    It needs to be open.

  3. #3
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Yes its open... but the file is opened from other PC...

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

    Re: VBA Countif -Out of range

    What do you mean "file is opened from other PC"?

  5. #5
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    I setting up 2 PC into single network use cross cable...

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

    Re: VBA Countif -Out of range

    That means it is not opened in your pc.

    Try something like
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Its worked.... thank you very much Sir Jindon….

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

    Re: VBA Countif -Out of range

    That's good and thanks for the rep.

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

  9. #9
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Hi Jindon, sorry. now the code is not working. when I try again it will not check the other file. It should check the data at PC2 file at sheet "Datas" range A:A. Is there I miss something here.
    Please Login or Register  to view this content.
    Thank you

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

    Re: VBA Countif -Out of range

    How is it not working?

    Is Mid(TextBox2.Text, 1, 8) a number?
    Please Login or Register  to view this content.
    Last edited by jindon; 02-04-2019 at 04:47 AM.

  11. #11
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Yes its a number.
    Last edited by Dean Zuki; 02-04-2019 at 09:32 PM.

  12. #12
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    1 more thing, current only check for 1 data how to extend into range A:A column?

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

    Re: VBA Countif -Out of range

    Show me your entire code and how you want the result.

  14. #14
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Hi Jindon, please see below. The result should prevent duplicate data between 2 workbook.

    Please Login or Register  to view this content.
    Thank you

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

    Re: VBA Countif -Out of range

    And what do you mean by
    Quote Originally Posted by Dean Zuki View Post
    1 more thing, current only check for 1 data how to extend into range A:A column?

  16. #16
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94
    Current code only able to check for 1st data only... After that it did not check for duplicate data from workbook 2...hope my explanation is clear ..

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

    Re: VBA Countif -Out of range

    Do you mean you want to count all the matched data in [Dean-Temp-PC2.xlsm]Datas Col.A?

    What for?

  18. #18
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Previous I use countif as per below code to check if the data exist. If exist, MsgBox appear "This Employee Number already exists". If not, copy the data to sheets "Datas".
    Please Login or Register  to view this content.
    Thank you

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

    Re: VBA Countif -Out of range

    Then you will need to open the workbook, Dean-Temp-PC2.xlsm in the same instance, and you also need to close it from other pc.

  20. #20
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    But both file need to run on the same time and cannot be close.... any advice...

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

    Re: VBA Countif -Out of range

    Why do you need to open the other workbook in the other pc?

    You CAN NOT add data while it is open somewhere.

  22. #22
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    If I want to check for duplicate data only? Is it possible? Reason for open 2 file (2 computer) when the crowd to huge my pos printer will jammed....
    Last edited by Dean Zuki; 02-04-2019 at 11:57 PM.

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

    Re: VBA Countif -Out of range

    Duplicate within Dean-Temp-PC2.xlsm?

    I asked about it already...What for?

    You should control it within Dean-Temp-PC2.xlsm.

  24. #24
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    To check Duplicate within Dean-Temp-PC2.xlsm & Dean-Temp-PC1.xlsm. Sorry ....

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

    Re: VBA Countif -Out of range

    What do you mean by "duplicates" exactly?

    Is it something to do with TextBox value, or duplicates against column to column?

    Post 2 workbooks and show me what exactly you wish to happen, otherwise I don't understand what you are trying to do.

  26. #26
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Hi Jindon, Yes, it is to do with Textbox value. Sorry for late reply. I having CNY Lion Dance ceremony. Please see attached file.

    tq
    Attached Files Attached Files

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

    Re: VBA Countif -Out of range

    Did you build all the codes attached to both files?

    I still don't understand what you are trying to do about "duplicate".

    Both files have no sheet called "Data", anyway...

  28. #28
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    No. I just google & modified to suit my need. Below original code from Holger who help me many years back.

    Please Login or Register  to view this content.

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

    Re: VBA Countif -Out of range

    Explain what do you want to happen exactly when you enter the number

    1) that already exists in other workbook.
    2) that is not in the other workbook.

    In detail.

  30. #30
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Here the scenario...
    1. Employees will swipe their ID card at PC1
    2. System will check whether he/she have swiped at PC2 (by checking their ID number at sheet "Datas")
    3. If their ID number already exist, system will reject their swipe
    4. IF not then the data will copy into sheet "datas" at file 1 (PC1)

    Note: the same process applied for file 2 at PC2. Hope my explanation clear ....sample print screen.jpg

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

    Re: VBA Countif -Out of range

    So, possibly multiple users would be entering the data at the same time.

    In that case Excel is not the software that you should use, learn ACCESS or other database software.

  32. #32
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Re: VBA Countif -Out of range

    Noted Sir Jindon. Thank you for your patience...

+ 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. Replies: 4
    Last Post: 02-24-2017, 02:06 AM
  2. if positive number in one range countif specific value in another range
    By sandreli in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-11-2016, 04:49 AM
  3. Replies: 1
    Last Post: 12-17-2015, 11:22 AM
  4. [SOLVED] Countif / Sumif Range in a 24 Hour Time Range
    By cwwazy in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-16-2013, 04:18 PM
  5. 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
  6. Replies: 15
    Last Post: 06-27-2011, 08:58 PM
  7. 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

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