+ Reply to Thread
Results 1 to 8 of 8

Compare column of word strings to a word document

  1. #1
    Registered User
    Join Date
    12-30-2010
    Location
    Boston
    MS-Off Ver
    Excel 2003
    Posts
    4

    Compare column of word strings to a word document

    Is it possible to create a formula in Excel that will compare (and count) the instances of a text string in column A to text in a word doc (or word doc)? For example; column A might contain 30 cells each with different strings. I would like each of those strings searched for within a defined text document for their appearance. I would like the result of the count located to be recorded in column B.

    thanks in advance
    Frank
    Last edited by cleanenergy; 12-30-2010 at 09:49 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,876

    Re: Compare column of word strings to a word document

    You can't do this with formulas. You would have to write a macro in VBA that would open the Word document and scan each word for a match, or do repeated finds, or something like that. How much effort is this worth?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    12-30-2010
    Location
    Boston
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Compare column of word strings to a word document

    I have a number of articles to manage daily and I must find an easier way to manage the relationship between these articles and the many long lists of words (and word phrases).

    Finding, counting, and reviewing each word (or phrase) has become tedious work going between applications to select a string, search for it, mark it, then review the use of it.

    If there is a better way I'm all for it, although I'd have to lobby for the change of processes here, but if it's more efficient that should be easy.

    Any thoughts?

  4. #4
    Registered User
    Join Date
    12-29-2010
    Location
    Europe, CET
    MS-Off Ver
    Excel 2004, Excel 2003, Excel 2007
    Posts
    15

    Re: Compare column of word strings to a word document

    This is doable in Excel without VBA. First, export your word file as ascii text (.txt). Then import this file into a new sheet in Exce (here: Sheet2)l, using the Data - Import text file tool. Make sure you make the file delimited, but remove all delimiters in the text file. Then each line in your text file will now be placed in a cell in your spreadsheet.

    Now, put your list of expressions in column A in another sheet (Sheet1). Then, in column B, you can use countif to do this, together with some wildcards for matching partial strings. The formula you would put in cell B1 would be:

    =COUNTIF(Sheet2!A:A,CONCATENATE("*",A1,"*")).

    Just tried it on a 40-page document. Quite nice actually - thanks for the question, this will come to good use! :-)

    BTW, I tried this on an article on cnn.com - works very well and quite fun. "Tea Party" seems to be the repeating term in articles on the GOP, the account of this ground-breaking research can be found at http://optkontek.blogspot.com/2010/1...r-phrases.html
    Last edited by optkontek; 12-30-2010 at 06:16 PM. Reason: funny experiment
    http://excelblog.optkontek.com - notes on excel
    Follow @nerdpub on twitter!

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Compare column of word strings to a word document

    although concatenate is useful its just easier to type "*"&a1&"*"
    =COUNTIF(Sheet2!A:A,"*"&A1&"*")
    Last edited by martindwilson; 12-30-2010 at 07:01 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,876

    Re: Compare column of word strings to a word document

    Quote Originally Posted by optkontek View Post
    ...Then each line in your text file will now be placed in a cell in your spreadsheet.
    This is a great idea, never would have thought of it. But won't it miss counts if the same word appears more than once in a line? Maybe importing it so it's one word per cell...?

  7. #7
    Registered User
    Join Date
    12-29-2010
    Location
    Europe, CET
    MS-Off Ver
    Excel 2004, Excel 2003, Excel 2007
    Posts
    15

    Re: Compare column of word strings to a word document

    That's a good point. One should really use whitespace as a delimiter then :-) Thanks for correcrting my suggestion!

  8. #8
    Registered User
    Join Date
    12-30-2010
    Location
    Boston
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Compare column of word strings to a word document

    Gee thanks!

    I always find it amazing how some people make some things look so easy. I have moments of course, it's just never while coding.
    Happy New Year!

+ 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