+ Reply to Thread
Results 1 to 6 of 6

count the number of members in cells seperated by ;

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    count the number of members in cells seperated by ;

    Hello,

    i have a big wordlist and I want to count the number of all members in its coulm D. And also need the number of members in each cell in column D. The number of signs or letters in each member should be counted as well. The seperator is ";"

    The macro is supposed to do:
    --> count the number of members of each cell in Column D and put that in Column F
    --> count the number letters or signs of each member and put the results in column E
    --> give the total number of cell members in Cell F1

    Thanks for each help in advance

    See the example image:
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    06-24-2008
    Location
    Cambridge UK
    Posts
    53
    Count the number of semicolons and add one?

  3. #3
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472
    Yes, but there are some empty cells as well. If a cell is empty then it would wrongly count it as one member, if only the ; are counted.

  4. #4
    Registered User
    Join Date
    06-24-2008
    Location
    Cambridge UK
    Posts
    53
    OK, so the logic would be something like:

    IF the cell is empty then 0;
    IF the cell has no semicolon then 1;
    In all other cases, (number of semicolons + 1)

    Or, more simply:

    IF (the cell is empty, 0, (number of semicolons + 1))

  5. #5
    Forum Contributor
    Join Date
    10-08-2006
    Location
    Walnut, CA
    MS-Off Ver
    2003,2010, Office 365
    Posts
    114
    Hi,
    Give this a try!
    Public Sub SplitIt()
    Dim lR As Long
    Dim i
    Dim x
    Dim j
    lR = Cells(Rows.Count, "D").End(xlUp).Row
    
    For i = 2 To lR
        x = Split(Cells(i, 4).Value, ";")
        For j = 0 To UBound(x)
            If j = 0 Then
                Cells(i, 5).Value = Len(x(j))
            Else
                Cells(i, 5).Value = Cells(i, 5).Value & ";" & Len(x(j))
            End If
        Next j
        Cells(i, 6) = UBound(x) + 1
    Next i
    Cells(1, 6).Formula = "=SUM(F2:F" & lR & ")"
    End Sub
    Tony

  6. #6
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472
    Thanks alot. Its working and its a great help. Thanks a million times

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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