+ Reply to Thread
Results 1 to 6 of 6

Help with formula to count number of occurances of texts from visible range

  1. #1
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Help with formula to count number of occurances of texts from visible range

    Hello All

    Can someone please help me with the following formula

    I have a formula which counts the number of occurrences of a certain text from a range (regardless of the upper or lower case) in a table.

    What I need to use subtotal function or anything else to only count the number of occurrences from a visible range so when a filter is applied to the table it only count the number of occurrences for the visible cells.
    my formula is

    Please Login or Register  to view this content.
    when I put subtotal(103,......) I get an error

    any help is appreciate it

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with formula to count number of occurances of texts from visible range

    Try a helper column, say column E
    E1 and Filled down put =SUBTOTAL(103,D1)

    Then use
    =SUMPRODUCT((LEN(Comments!$D:$D)-LEN(SUBSTITUTE((UPPER(Comments!$D:$D)),UPPER(A2),"")))/LEN(A2),$E:$E)

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with formula to count number of occurances of texts from visible range

    However, Might I suggest the simpler COUNTIF function

    =COUNTIF(Comments!$D:$D,"*"&A2&"*")

    Then to do just the visible cells only, use the same subtotal in column E as in previous post
    And use
    =COUNTIFS(Comments!$D:$D,"*"&A2&"*",Comments!$E:$E,1)



    FYI, I highly recommend NOT using entire column references like D:D in sumproduct.

  4. #4
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with formula to count number of occurances of texts from visible range

    Dear Jonmo

    Thank you so much for your help, both ideas worked brilliantly, and I have used a range rather than column and it is much quicker.

    I was wondering whether there is a way to do this without the helper column, as I export the table by VB code into the Comments sheet and the formula is in different sheet. If not that's not a problem as I have to somehow write a vb code to automatically insert the helper column . Reason is when I refresh the data the code deletes the table and inserts a new one (exactly the same dimensions) .

    However your solution works fantastically and I just add a code for the extra column.

    Tanks again for your help

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with formula to count number of occurances of texts from visible range

    You're welcome.

    I know it 'Can' be done in one formula, I'm sure there are some other formula guru's that can do it.
    I just prefer to use the helper column method (personal choice)
    Because I figure once you have 1 formula that you need to ignore hidden rows, you will likely have another and another...
    You would have to repeat that subtotal work in each formula.
    So putting the subtotal work in each formula itself, that is creating alot of unnecessary work = poor performance of your sheet.

    With the helper column, you only do the subtotal work once.
    Then all of your other formulas that need to ignore hidden rows can each refer to that same helper column.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Help with formula to count number of occurances of texts from visible range

    Quote Originally Posted by rv02 View Post
    I was wondering whether there is a way to do this without the helper column
    Can you post a SMALL sample file that shows us what result you expect?

    No more than 20 rows and as few columns worth of data is plenty. We don't want to have to sift through tons of irrelevant data looking for the solution!
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ 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. Formula to count number of visible rows, and formula to count visible blanks
    By radoncadonc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-28-2015, 04:19 PM
  2. [SOLVED] Count the number of unique values (occurances) in a range.
    By angelopc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-13-2013, 10:36 AM
  3. [SOLVED] Count number of occurances below a range, within a range, and below a range
    By maacmaac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2013, 11:36 PM
  4. count occurances of range of numbers in unknown number of cells.
    By gammaman in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 10-12-2012, 06:27 AM
  5. Can you create a formula that will count the occurances of a number (say "25")
    By allenratta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-01-2012, 02:49 AM
  6. Count the number of occurances of a value in a range.
    By pi**edasanewt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-15-2008, 07:08 AM
  7. count number of occurances of a word in a range
    By John Davies in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-24-2006, 09:50 AM

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