+ Reply to Thread
Results 1 to 14 of 14

Count the number of times a text pattern is used

Hybrid View

  1. #1
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Count the number of times a text pattern is used

    Hi, there was a problem with the formula to get the number of unique lines (the evaluate bit), it was returning .999999 instead of an integer. If you add a round function it should be ok:
    Sub macro_1()
    Dim count, pattern_array, no_patterns, i
    no_patterns = Round(Evaluate("=SUMPRODUCT((A2:A13000<>"""")/COUNTIF(A2:A13000,A2:A13000&""""))"), 0)
    ReDim pattern_array(1 To no_patterns, 1 To 1)
    For count = 2 To Range("A" & Rows.count).End(xlUp).Row
        If Range("A" & count - 1) <> Range("A" & count) Then i = i + 1
        pattern_array(i, 1) = pattern_array(i, 1) & "," & Range("B" & count)
    Next count
    Range("D2:D" & no_patterns + 1).Value = pattern_array
    With Range("E2:E" & no_patterns + 1)
        .Formula = "=countif(D$2:D$" & no_patterns + 1 & ",D2)"
        .Value = .Value
    End With
    For count = Range("D" & Rows.count).End(xlUp).Row To 2 Step -1
      If Range("D" & count) = Range("D" & count - 1) Then
        Range("D" & count & ":E" & count).Delete xlUp
      Else
        Range("D" & count) = Right(Range("D" & count), Len(Range("D" & count)) - 1)
      End If
    Next
    End Sub

  2. #2
    Registered User
    Join Date
    05-19-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Count the number of times a text pattern is used

    Many thanks for your help.
    Issue solved

+ 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. Count the number of times a particular text appears in group of cells
    By L.LEE in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-29-2013, 04:16 AM
  2. Macro to Count the number of Rows between a text value that occurs mutliple times
    By AdamMoffitt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2013, 11:34 AM
  3. Count the number of times a specific text appears in column D
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2011, 02:02 PM
  4. Counting number of times a Text pattern appeared in a range
    By khalidawan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2008, 05:35 AM
  5. [SOLVED] how do I count the number of times text in column A matches text i
    By Sheila in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-16-2005, 06:25 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