VBA: Parsing with Excel and Word

  • I am trying to write a macro that takes individual cells from and Excel worksheet, and uses the data in the cell to Find that same data in a Word document. If there is a match in Word I have to parse the text after the data, whatever it may be.


    Example:


    AA456789 GENE


    AA456789 would have been the data in the Excel cell and I would've used that to search for in the Word document. If it found something, like in the example, it would extract the text after the data (in this case GENE) and paste it onto the cell to the right of the searched for data. After its done with one it goes to the next one.


    Any help on this would be greatly appreciated.

  • Hi -


    Is your word document all formatted like your example, i.e.


    AA456789 GENE
    BB123455 PAUL
    CC123 JOHN
    ZZ9999 JANE


    etc.


    If so, it would be a lot easier to perform a "convert text to table" operation in Word, then copy and paste the table into excel. Then you could do your cell merges with VLOOKUP and CONCANTENATE functions.


    (is this the same question you posted today under VBA: Help with Excel and parsing a txt document ?)


    Hope this helps


    .....Ralph

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!