Application-defined or object_defined error

  • this line gives me an error:
    firstboguscc = Application.CountIf(Workbooks("usertemp.xls").Worksheets("Sheet1").Range("AF"), crit)


    I don't know why
    firstboguscc is defined at a string
    crit is defined as a string


    If i use the line in the active worksheet like this:
    firstboguscc = Application.CountIf(Range("AF"), crit)
    it works fine. But if i want to count the instances of crit in another workbook, i get an "Application-defined or object_defined error" Must be in the syntax but I can't figure it out.

  • Re: Application-defined or object_defined error


    Quote from Logit;791453

    Post your workbook ?


    No confidential info.


    I got it to work by making the other workbook active, doing the countif, and then coming back to the orginal workbook

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!