+ Reply to Thread
Results 1 to 15 of 15

countif loop through range

  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    countif loop through range

    I'm having trouble with my variable range for my countif.

    I am trying to loop through the range A4:A (bottom row based on Brow). one cell at a time (j) but I am having trouble setting the range for the countif.

    Can anyone suggest what I am doing incorrectly so I may recitfy the code?


    Please Login or Register  to view this content.
    Last edited by Sc0tt1e; 11-02-2018 at 08:04 AM. Reason: added missing "]" on /code tag

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: countif loop through range

    "I am having trouble" What is the trouble? That is, what do you want to happen, and what is happening instead? If you get a runtime error include the error message.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: countif loop through range

    Please Login or Register  to view this content.
    shoud that be
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: countif loop through range

    Run time error 438
    Object doesnt support this property or method

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: countif loop through range

    It is worth declaring all variables, so that the code could easilly spot an error

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: countif loop through range

    That still produces the same error

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: countif loop through range

    I run a test and did not get any error.

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,918

    Re: countif loop through range

    That loop doesn't look right to me. I think you want:

    Please Login or Register  to view this content.
    unless you really want to skip the first three cells of the range.
    Rory

  9. #9
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: countif loop through range

    Quote Originally Posted by rorya View Post
    That loop doesn't look right to me. I think you want:

    Please Login or Register  to view this content.
    unless you really want to skip the first three cells of the range.
    I do, the headings start on row 3, the data starts on row 4

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,918

    Re: countif loop through range

    Your range is set to start from row 4 already, but your loop is skipping the first three cells of that range - i.e. rows 4, 5 and 6.

  11. #11
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: countif loop through range

    I thought that might be happening so was going to test it, that still doesn't explain why I keep getting the error message on the countif row though?

    I have no message when I compile the code, only when I run it.

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,918

    Re: countif loop through range

    Using what code exactly?

  13. #13
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: countif loop through range

    Please Login or Register  to view this content.
    I've tried researching the error message just not understanding its context in this situation.


    Symptoms
    Error 438 occurs when running a program in which a form is assigned to a variable and that variable is used to access a control on the form if the program is on a system running Windows 95 with Regional Settings set to a setting other than English (United States). The error text is:

    Run-Time Error #438:
    Object doesn't support this property or method

    Resolution
    There are two possible workarounds for this problem.

    Access the form directly rather than by a variable containing the form.
    -or-
    Create property procedures in the form's code to provide access to the properties of the controls on the form.
    Last edited by Sc0tt1e; 11-02-2018 at 08:58 AM.

  14. #14
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,918

    Re: countif loop through range

    It's WorksheetFunction.CountIf and not Worksheet.Function.CountIf.

  15. #15
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: countif loop through range

    Quote Originally Posted by rorya View Post
    It's WorksheetFunction.CountIf and not Worksheet.Function.CountIf.
    FFS

    Thanks rorya, it's always a fullstop

+ 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. Populate Countif values (Offset) into Array and loop through it
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-16-2017, 05:55 AM
  3. [SOLVED] Loop Column reference in VBA Countif
    By jeffreybrown in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2016, 10:53 PM
  4. Why is my nested countif loop wrong
    By falco008 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2016, 06:07 AM
  5. COUNTIF-type loop with multiple logic requirements?
    By reagent in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-30-2013, 03:19 AM
  6. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  7. 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

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