+ Reply to Thread
Results 1 to 10 of 10

count duplicated string in Range for each letter,Non Adjacent Row

Hybrid View

david gonzalez count duplicated string in... 10-21-2014, 09:46 PM
canapone Re: count duplicated string... 10-21-2014, 11:01 PM
gak67 Re: count duplicated string... 10-21-2014, 11:08 PM
david gonzalez Re: count duplicated string... 10-21-2014, 11:21 PM
xladept Re: count duplicated string... 10-22-2014, 03:04 PM
david gonzalez Re: count duplicated string... 10-23-2014, 01:50 PM
xladept Re: count duplicated string... 10-23-2014, 06:38 PM
david gonzalez Re: count duplicated string... 10-24-2014, 03:13 PM
xladept Re: count duplicated string... 10-24-2014, 06:41 PM
xladept Re: count duplicated string... 10-25-2014, 04:00 PM
  1. #1
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    count duplicated string in Range for each letter,Non Adjacent Row

    Hi !!

    please need some advice on this formula, i'm receiving 1 as result

    What i'm trying to achieve is to Count the occurrences of each number In range EW3:FA38 with each Alphabet
    In Range FK3:FK38
    Example :
    #24 = 2 occurrences with letter A
    #29 = 2 occurrences with letter A:

    I'm using this formula
    =COUNT(IF((FK3:FK38="A")*(AA3:AA38="3"),EW3:FA38))
    and i'm getting result 1, i Tried a sum,sumproducts with countif, and still..
    =SUMPRODUCT(COUNTIF(EW$3:FA$9,INDEX(FK$3:FK$9,MATCH(AA9,FK$3:FK$9,0),0)))
     =SUM(COUNTIFS($EW$3:$FA$38,AA3,$FK$3:$FK$38,"A"))


    Thank you !
    Attached Files Attached Files
    Last edited by david gonzalez; 10-21-2014 at 09:54 PM. Reason: forgot to add Non adjacent word

  2. #2
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    Hi David,

    one way could be

    Formula: copy to clipboard
    =SUMPRODUCT(($FK$3:$FK$38="A")*($EW$3:$FA$38=29))


    In AB3 and below:

    Formula: copy to clipboard
    =SUMPRODUCT(($FK$3:$FK$38="A")*($EW$3:$FA$38=AA3))


    Greetings
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  3. #3
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    Try this formula in AB3 and drag it down:
    Formula: copy to clipboard
    =SUMPRODUCT(($EW$3:$FA$38=AA3)*($FK$3:$FK$38=RIGHT($AB$2,1)))
    Please add reputation by clicking on the * if I have helped.
    Please mark the thread SOLVED if your issue has been resolved.
    Thanks, Glenn.

  4. #4
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    HI,

    Thank you Mr Canapone and Mr gak67,

    both formulas work good, i have no more rep for today, tomorrow will be another day..Sorry for today Mr gak67..
    i keep you on mind, great job


    Thank you !!!


    David

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    Hi David,

    A small contribution:

    Sub Poquito(): Dim r As Long, c As Long, Key As String, k
    With CreateObject("Scripting.Dictionary")
    For r = 3 To 38: For c = 153 To 157
    Key = Cells(r, c) & "_" & Cells(r, 167)
    If .Exists(Key) Then
    .Item(Key) = .Item(Key) + 1
    Else
    .Item(Key) = 1: End If
    Next c: Next r
    k = .Keys()
    BubbleK:
            For r = LBound(k) To UBound(k) - 1
            If Val(Mid(k(r), 1, InStr(1, k(r), "_") - 1)) > _
            Val(Mid(k(r + 1), 1, InStr(1, k(r + 1), "_") - 1)) Then
        Key = k(r): k(r) = k(r + 1): k(r + 1) = Key
             GoTo BubbleK: End If: Next r
             
    Cells(3, 169).Resize(UBound(k) + 1, 1).Value = WorksheetFunction.Transpose(k)
    For r = 3 To UBound(k) + 4: Key = Cells(r, 169): Cells(r, 170) = .Item(Key): Next r
    End With: End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  6. #6
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    Hi Mr Xladept,

    Thank you for your big contribution...
    You're right about to apply code on this, because of the delete accident.. lol
    code is excellent and i'm going to use it, But let me ask you :

    I was trying to figure it how to modify the code and write the total occurrences on each letter column?
    For example, to write the total occurrences on a column called "A" , Then i think i can figure for next Letter "C", "E"....."W"
    Please see attached Pic.

    PatternoccurrencesSample.png





    Thank you so much !!


    David
    Last edited by david gonzalez; 10-23-2014 at 01:50 PM. Reason: misspelling Your word and corrected

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    Hi David,

    Thanks for the rep!

    See if this works for you (I couldn't upload your image): Pequeno.xlsb

    Sub Pequeno(): Dim r As Long, c As Long, Key As String, k, er As Long, S As String
    With CreateObject("Scripting.Dictionary")
    For r = 3 To 38: For c = 153 To 157
    Key = Cells(r, c) & "_" & Cells(r, 167)
    If .Exists(Key) Then
    .Item(Key) = .Item(Key) + 1
    Else
    .Item(Key) = 1: End If
    Next c: Next r
    k = .Keys(): er = UBound(k) + 1
    BubbleK:
            For r = LBound(k) To UBound(k) - 1
            If Val(Mid(k(r), 1, InStr(1, k(r), "_") - 1)) > _
            Val(Mid(k(r + 1), 1, InStr(1, k(r + 1), "_") - 1)) Then
        Key = k(r): k(r) = k(r + 1): k(r + 1) = Key
             GoTo BubbleK: End If: Next r
             
    Cells(3, 169).Resize(UBound(k) + 1, 1).Value = WorksheetFunction.Transpose(k)
    For r = 3 To er + 2: Key = Cells(r, 169): Cells(r, 169).Resize(1, 2).Value = Split(Key, "_")
    Cells(r, 171) = .Item(Key): Next r
    Range(Cells(3, 169), Cells(er + 2, 171)).Sort Key1:=Cells(3, 170), Header:=xlNo
    For r = 3 To er + 2
    S = Cells(r, 170) & Cells(r, 169): Range(S) = Cells(r, 171)
    Next r
    End With: End Sub

  8. #8
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    Hi Mr xladept,

    Thank you so much for the code pequeño, is amazing !!

    ayy caramba !!


    Best Regards

    David

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    Hi David,

    Thanks for the rep - glad you like the code - if the end result is all you need we can code that more elegantly!

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: count duplicated string in Range for each letter,Non Adjacent Row

    Hi David,

    Here's a more elegant routine with a less elegant name:Pequeno.xlsb

    Sub Pulgar(): Dim r As Long, c As Long, Key As String, k, S As String, A
        A = Array("A", "C", "E", "G", "I", "K", "M", "O", "Q", "S", "U", "W")
            With CreateObject("Scripting.Dictionary")
            For r = 3 To 38: For c = 153 To 157
                Key = Cells(r, 167) & Cells(r, c)
                    If .Exists(Key) Then
                        .Item(Key) = .Item(Key) + 1
                    Else
                        .Item(Key) = 1: End If
            Next c: Next r: k = .Keys()
                    For r = 3 To UBound(k)
            S = Left(k(r), 1): For c = 0 To UBound(A)
                                If A(c) = S Then Exit For
                                Next c
            Range(k(r)).Offset(0, 30 + 7 * c) = .Item(k(r))
                    Next r: End With: End Sub
    * I think that this is what you requested?

+ 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. sum of a range of values based on count of occurrence of letter in range
    By vsbhogar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-08-2013, 01:02 PM
  2. Replies: 6
    Last Post: 07-03-2011, 08:08 PM
  3. count cell range with a certain letter
    By Damon James in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-19-2011, 09:01 AM
  4. [SOLVED] How can I count the number of times a letter repeats in a string?
    By Wiley in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-11-2006, 02:00 PM
  5. count a number range and a letter in a cell
    By santaviga in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-28-2006, 06:15 AM

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