+ Reply to Thread
Results 1 to 3 of 3

Count consecutive letters in columns

  1. #1
    Registered User
    Join Date
    06-12-2018
    Location
    Amsterdam
    MS-Off Ver
    Office 365
    Posts
    2

    Talking Count consecutive letters in columns

    Hi All!
    I´m new with excel and I would know if someone could help me with this I would appreciate so much!:
    If I had a column in cells for example
    v
    x
    x
    v
    v
    x
    x
    x
    v
    v
    v
    x


    I found the way to count couple "vv" or "xx" counting the "vvv" and doing 3-1 or "vvvv" = 4-1= 3 couples presence.

    Now how should I do to find "xv" and "vx" numbers of couples present in that column that is very long 1000 cells for example?

    Thank You !

    Gitano

  2. #2
    Registered User
    Join Date
    06-12-2018
    Location
    Amsterdam
    MS-Off Ver
    Office 365
    Posts
    2

    Re: Count consecutive letters in columns

    Ok,
    to find the "vvv" for example I used this where I put the goal number for example 3 and after I do 3-1 to find my number " 2 couples"
    -------------------------------------------------------------------------------------------------------------------

    Function Contig(ByRef Myaddr As Range, ByVal myVal As String, ByVal myGoal As Integer) As Integer
    For Each cell In Myaddr
    If cell.Value = myVal Then
    ccnt = ccnt + 1
    Else
    If ccnt = myGoal Then Contig = Contig + 1
    ccnt = 0
    End If
    Next cell
    End Function

    --------------------------------------------------------------------------------------------------

    How I can modify this to find xv or vx ? Or there is a function or another macro?
    Thank a Lot !
    Gitano

  3. #3
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,556

    Re: Count consecutive letters in columns

    Hello Gitanos and Welcome to Excel Forum.
    I don't know how you would do this with VBA, however the following formula will work, yields 5 for the sample in post #1:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that the data found in post #1 is in A1:A12, cell C2 contains the letter v and cell D2 contains the letter w.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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: 13
    Last Post: 07-15-2017, 09:47 AM
  2. Need to count consecutive letters and then deduct lowecase
    By bahanley in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-16-2016, 04:39 PM
  3. Replies: 5
    Last Post: 08-16-2015, 09:55 PM
  4. Replies: 3
    Last Post: 08-16-2015, 07:03 PM
  5. [SOLVED] Sort on whether cell contains 2 consecutive capital letters
    By greek in forum Excel General
    Replies: 12
    Last Post: 06-16-2014, 08:07 AM
  6. [SOLVED] How to count consecutive columns
    By adrianplunkett in forum Excel General
    Replies: 13
    Last Post: 05-21-2012, 10:02 AM
  7. [SOLVED] Count non consecutive columns
    By [email protected] in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-23-2006, 10:30 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