Results 1 to 5 of 5

Tagged word / phrase count VB help please

Threaded View

  1. #1
    Registered User
    Join Date
    09-08-2016
    Location
    Middlesbrough
    MS-Off Ver
    2010
    Posts
    7

    Tagged word / phrase count VB help please

    Hi all,

    I am using the following VB code (which i didn't write) to count occurrence of individual words contained in all the rows in column A to help look for trends.

    Sub HTH() 
        Dim vArray As Variant 
        Dim lLoop As Long 
        Dim rCell As Range 
         
        With CreateObject("Scripting.Dictionary") 
            For Each rCell In Range("A1", Cells(Rows.Count, "A").End(xlUp)) 
                vArray = Split(rCell.Value, " ") 
                For lLoop = LBound(vArray) To UBound(vArray) 
                    If Not .exists(vArray(lLoop)) Then 
                        .Add vArray(lLoop), 1 
                    Else 
                        .Item(vArray(lLoop)) = .Item(vArray(lLoop)) + 1 
                    End If 
                Next lLoop 
            Next rCell 
            Range("B1").Resize(.Count).Value = Application.Transpose(.keys) 
            Range("C1").Resize(.Count).Value = Application.Transpose(.items) 
        End With 
    End Sub 
    
    This works well but in reality i need it to be altered (very much like the tags on this forum) so that it will look at all rows in column A and recognise that tags are separated by # so for example a row could contain:

    #housing #VOIDS #rent arrears #new builds

    The code would need to return everything to the right of the # as a separate tag until it found another tag or until the cell was empty.

    This would be an example of a few rows of data in column A:


    ROW 1 #housing #VOIDS #rent arrears #new builds
    ROW 2 #housing #arrears #tenant support
    ROW 3 #assisted living #payments
    ROW 4 #insurance
    ROW 5 #supported housing #tenant support

    For this data the VB should return the following

    housing 2
    VOIDS 1
    rent arrears 1
    new builds 1
    arrears 1
    assisted living 1
    payments 1
    insurance 1
    supported housing 1
    tenant support 2

    Any help would be very much appreciated.

    Thank you in advance.
    Last edited by fairlo; 09-08-2016 at 05:33 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Include random word from the word list with a phrase as suffix or prefix
    By faizzsheikh in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-10-2016, 05:53 AM
  2. [SOLVED] can't search word or phrase in my database
    By kensho in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-15-2015, 06:01 AM
  3. [SOLVED] Search using a Word/Phrase
    By hiteshasrani43 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-05-2015, 01:02 AM
  4. Replies: 5
    Last Post: 10-15-2014, 03:38 PM
  5. Highlighting a word or phrase
    By bishoposiris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2013, 11:11 PM
  6. [SOLVED] Returning Value if cell contains certain word/phrase
    By Montoro22 in forum Excel General
    Replies: 4
    Last Post: 08-13-2012, 03:35 PM
  7. Translate a word into a phrase.
    By STSOM in forum Excel General
    Replies: 1
    Last Post: 01-02-2009, 11:19 AM

Tags for this Thread

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