Results 1 to 1 of 1

Word Count VBA Code Adjustment

Threaded View

skate1991 Word Count VBA Code Adjustment 09-06-2012, 06:28 AM
  1. #1
    Forum Contributor
    Join Date
    11-08-2011
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    279

    Word Count VBA Code Adjustment

    HI,

    I have the below code to count the number of words in an excel spreadsheet.

    Is there a way to exclude text that has been strikethrough.

    Sub CountWords()
        Dim WordCount As Long
        Dim Rng As Range
        Dim S As String
        Dim N As Long
        For Each Rng In ActiveSheet.UsedRange.Cells
            S = Application.WorksheetFunction.Trim(Rng.Text)
            N = 0
            If S <> vbNullString Then
                N = Len(S) - Len(Replace(S, " ", "")) + 1
            End If
            WordCount = WordCount + N
        Next Rng
        MsgBox "Words In ActiveSheet Sheet: " & Format(WordCount, "#,##0")
    End Sub



    Thanks
    Last edited by arlu1201; 09-06-2012 at 07:03 AM. Reason: Code tags for 1st post.

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