+ Reply to Thread
Results 1 to 3 of 3

displaying number of times a word occurs in a table column with VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    05-05-2015
    Location
    lomita
    MS-Off Ver
    office enterprise 2007
    Posts
    34

    displaying number of times a word occurs in a table column with VBA

    Hi i am looking for some assistance on how i can display the Number of times a word or phrase occurs using a user form.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    01-08-2016
    Location
    Cagayan De Oro City, Philippines
    MS-Off Ver
    2013
    Posts
    152

    Re: displaying number of times a word occurs in a table column with VBA

    Hi

    just add this to a VBA Module, or the sheet code and run it, it will check all the cells of the active sheet for a specific text and tell you how many times it occurs, not case sensitive.....

    Public Sub CountText()
        Dim Arr As Variant
        Dim i As Long, j As Integer
        Dim ST As String
        Dim STLen As Integer
        Dim FindIndex As Integer
        Dim StopSearch As Boolean
        Dim Cnt As Long
        Dim S1 As String
        
        ST = LCase(InputBox("Find"))
        
        If Trim(ST) = vbNullString Then Exit Sub
        
        Arr = ActiveSheet.UsedRange.Value
    
        For i = LBound(Arr, 1) To UBound(Arr, 1)
            For j = LBound(Arr, 2) To UBound(Arr, 2)
                If STLen < Len(Arr(i, j)) Then
                    
                    FindIndex = 0
                    StopSearch = False
                    S1 = LCase(Arr(i, j))
                    
                    While Not StopSearch
                        FindIndex = InStr(FindIndex + 1, S1, ST)
                        If FindIndex > 0 Then
                            Cnt = Cnt + 1
                        Else
                            StopSearch = True
                        End If
                    Wend
                End If
            Next j
        Next i
        
        MsgBox "Found " & Cnt & " time(s)"
    End Sub
    should give you what you want, if you need help just post back, someone will help

  3. #3
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: displaying number of times a word occurs in a table column with VBA

    Option Explicit
    
    Sub count()
    Dim term As String
    term = "*" & InputBox("searched term:") & "*"
    MsgBox Application.WorksheetFunction.CountIf(ActiveSheet.UsedRange, term)
    
    End Sub
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

+ 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. [SOLVED] How to sum the number of times a value occurs in a column?
    By bk01eeh in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-30-2015, 11:20 AM
  2. [SOLVED] Counting Number of Times A Sum Occurs
    By Jennifer2010 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-15-2015, 10:53 PM
  3. [SOLVED] Locating the row number in which the a specific word occurs in a column.
    By joebonz in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-23-2015, 03:56 PM
  4. [SOLVED] Count how many times a word occurs in a cell containing text
    By frisbie17 in forum Excel General
    Replies: 2
    Last Post: 08-01-2012, 02:31 PM
  5. [SOLVED] counting number of times a year occurs in a column range
    By mistert in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-26-2012, 12:20 PM
  6. Counting Number of Times a Numerical Response Occurs in Column
    By alex.salkever in forum Excel General
    Replies: 1
    Last Post: 09-18-2008, 02:03 AM
  7. How do I calculate times each word occurs in a column of cells?
    By MTSusce in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-18-2006, 08:35 PM

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