+ Reply to Thread
Results 1 to 6 of 6

Using COUNTIF for a user-defined range

  1. #1
    Registered User
    Join Date
    01-12-2020
    Location
    Philadelphia, PA
    MS-Off Ver
    2016
    Posts
    97

    Using COUNTIF for a user-defined range

    Obviously, we can use COUNTIF("TEXT",A1:A100) to count how many times a specific string appears within a range, but what if the range is user-defined or variable? In other words, how could a user choose if they want to search ONLY the top 10 (A1:A10), top 20 (A1:A20) etc?

    Thanks!

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,607

    Re: Using COUNTIF for a user-defined range

    Using E1 for the rows to include:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by protonLeah; 01-04-2022 at 07:41 PM.
    Ben Van Johnson

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Using COUNTIF for a user-defined range

    Mmmm, actually, it's =COUNTIF(A1:A100, "TEXT")

    Some options:

    =COUNTIF(A1:A100, "TEXT")
    =COUNTIF(A1:INDEX(A:A,10), "TEXT")
    =COUNTIF(A1:INDEX(A:A,MAX(D1,1)), "TEXT")
    D1=5, say
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Using COUNTIF for a user-defined range

    Ah, just a bit too slow ...

  5. #5
    Registered User
    Join Date
    01-12-2020
    Location
    Philadelphia, PA
    MS-Off Ver
    2016
    Posts
    97

    Re: Using COUNTIF for a user-defined range

    protonLeah, Thank you so much! But please also share with me how you got to put all that extra text in E1. I wouldn't even know how to look that up!

    UPDATE: Never mind, figured it out!
    Last edited by CriticalMass048; 01-10-2022 at 01:56 PM.

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,607

    Re: Using COUNTIF for a user-defined range

    I selected E1 and applied custom number format "count " # " rows"

+ 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. How to set Range as a User-Defined variable
    By Ulnarian in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-05-2019, 10:24 AM
  2. Copy, paste, replace- user defined range in all the defined sheets
    By aganesan99 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2014, 12:28 PM
  3. User Defined Print Range in VBA
    By mburke05 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2013, 05:03 PM
  4. Gather a sum of cells within a user-defined range
    By baiken in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-05-2012, 03:14 AM
  5. Subs and user-defined range - how to reference the U/D range?
    By D_N_L in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-26-2011, 09:08 AM
  6. user defined range in VBA
    By cubinity in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-13-2011, 08:55 PM
  7. How to: User Form to assign a user defined range to a macro variab
    By TrevTrav in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2005, 04: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