+ Reply to Thread
Results 1 to 3 of 3

countif until last row

Hybrid View

ecsabi countif until last row 03-24-2013, 07:16 AM
martindwilson Re: countif until last row 03-24-2013, 07:56 AM
ecsabi Re: countif until last row 03-24-2013, 09:22 AM
  1. #1
    Registered User
    Join Date
    03-16-2013
    Location
    Havant, UK
    MS-Off Ver
    Excel 2010
    Posts
    2

    countif until last row

    Hi,

    I want to use SUMIF and COUNTIF until last row.
    The SUMIF function works nicely but I get 'application-defined or object-defined error' on the COUNTIF function.

    LastRow = Cells(Rows.Count, "A").End(xlUp).Row

    Range("AE1").Select
    ActiveCell.FormulaR1C1 = "Cur PO activity"
    ActiveCell.Offset(1, 0).Range("A1").Select
    ActiveCell.Formula = _
    "=IF(SUMIF($H$2:$H$" & LastRow & ",$H2,AD$2:AD$" & LastRow & ")>0,""Y"",""N"")"
    ActiveCell.Offset(-1, 1).Range("A1").Select
    ActiveCell.FormulaR1C1 = "# of docs/PO"
    ActiveCell.Offset(1, 0).Range("A1").Select
    ActiveCell.FormulaR1C1 = "=COUNTIF($H$2:$H$" & LastRow & ",$H2)"

    What did I wrong in the last line?

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: countif until last row

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code in [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    but look at this
    ActiveCell.FormulaR1C1 = "=COUNTIF($H$2:$H$" & LastRow & ",$H2)"
    ActiveCell.Formula = "=COUNTIF($H$2:$H$" & LastRow & ",$H2)"
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    03-16-2013
    Location
    Havant, UK
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: countif until last row

    Thanks very much.

    It works. I will use code tags next time, sorry.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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