double quote usage with Evaluate function

  • Hi Everyone,
    I had lots of help over years, so thanks to all contributers, I am trying to feed the forum back in these days;
    Below small piece of code does not work, any idea?
    thanks

    Code
    MsgBox Evaluate("=CountA(SourceWB.Worksheets(1).range(""B:B""))")


    neither this;

    Code
    MsgBox Evaluate("=CountA(SourceWB.Worksheets(1).range("B:B"))")

    i love flamenco

  • Re: double quote usage with Evaluate function


    The Evaluate method only works for Excel formulas as they would be entered directly into an Excel cell. You are mixing the use of an Excel formula using COUNTA with VBA syntax. You need:

    Code
    MsgBox Evaluate("COUNTA('" & SourceWB.Worksheets(1).Name & "'!B:B)")


    or

    Code
    MsgBox WorksheetFunction.CountA(SourceWB.Worksheets(1).Range("B:B"))
  • Re: double quote usage with Evaluate function


    Thanks Rob, great help! Especially the first one is very interesting. appreciate that.

    i love flamenco

Participate now!

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