# Count consecutive letters in columns

1. ## 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. ## 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
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. ## 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:
`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.

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### 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