+ Reply to Thread
Results 1 to 5 of 5

wrong result of worksheetFunction.countif

  1. #1
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    wrong result of worksheetFunction.countif

    Hi experts,

    i am doing a macro where i want to restrict double file entry while extraction.

    i set the the "Log" sheet name where i write all the filename in B column.

    Start of the macro i have check the filename in sheets("Log") is exists or not

    this is the code i have set
    Please Login or Register  to view this content.
    if i run macro for first time of Feb Month then it shows me correct result because Log sheet have no filename.
    but if i run second time of same Month (Feb) then it also run but output is totally blank.
    i checked the count of running file in msgbox then it show me 0 value but same file is exist in Log Sheet

    how this happening?
    Please suggest me

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: wrong result of worksheetFunction.countif

    But what is the value of sfilename. May be problem is here?

    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: wrong result of worksheetFunction.countif

    Hi Kaper,

    thanks for reply
    sFilename have no problem.
    because same filename i have write on first time run
    so when i run second time it should be 1 or more but it show me 0 so my code take all the steps which i set to ignore.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623
    Anyway, I'd expect problem with it. May be sfilename has a name and path, and you write just name? Or oposite? May be value of this variable has changed or is set out of the scope of your current procedure?

    BTW: have you tried my simple code? Or just answeered "no, I'm sure it's not the case" - sorry for asking, but it's quite common attitude on forums.

    May be there are merged cells? And may be you do not write your values to column B indeed.

    Last suggestipn is (as almost always): attach sample file.
    Last edited by Kaper; 10-22-2018 at 07:04 AM.

  5. #5
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: wrong result of worksheetFunction.countif

    thanks Kaper,

    yes i tried all the way (may be some silly mistake still left ) but my result is same. any way i will do it some another way

    thanks again Kaper

+ 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. Countif in VBA returns wrong result.
    By bebo021999 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-05-2016, 02:33 AM
  2. [SOLVED] WorksheetFunction.VLookup doesnt work if result is #N/A
    By HerryMarkowitz in forum Excel - New Users/Basics
    Replies: 9
    Last Post: 03-11-2015, 10:40 AM
  3. [SOLVED] Code result wrong but formula correct result
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-11-2014, 12:26 PM
  4. Replies: 14
    Last Post: 03-21-2012, 02:38 PM
  5. function with WorksheetFunction.VLookup. whats wrong?
    By struggleforlife in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2008, 01:43 PM
  6. excel result return wrong calcuation result
    By garyww in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-14-2006, 06:20 AM
  7. 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