Using VBA to search data in a .docx and return it in Excel... with a tiny twist

Sadsmileyface

New Member
Joined
Mar 21, 2013
Messages
11
I had some lifesaving advice on here a while back and it's peaked my curiosity with what I can do. I've had a conundrum and have been Googling the answer to try to find it on my own without having to resort to asking but I've hit a brick wall. I'm kind of doubting this can be done.

I have a folder full of word docs, all in a similar format. In each word doc, I want Excel to open and search for a text string (as predetermined in cells in excel) and return the value it find after a colon, and past it into a cell. That's mostly easy.

Then, I want to search for a string in the doc again and return something like true or false in the adjacent cell in Excel. Again, not too bad.

However, my problem is that that second set of strings we're searching for are not necessarily going to be unique in the document. The only thing to differentiate them will be a heading above them. I've illustrated this here (strings in italics are searched, bold is returned strings, underlined is logic):


Name: JOHN SMITH
Date: 10-Mar-2018
Level: 1
Code Reference: 2.1.2 A RETURN TRUE OR FALSE
Code Reference: 2.1.2 B RETURN TRUE OR FALSE
Code Reference: 2.1.2 C RETURN TRUE OR FALSE
Level: 2
Code Reference: 2.1.2 A RETURN TRUE OR FALSE
Code Reference: 2.1.2 B RETURN TRUE OR FALSE
Code Reference: 2.1.2 C RETURN TRUE OR FALSE




So then we'd want to populate a range like this in Excel:

Name

<tbody>
</tbody>
Date

<tbody>
</tbody>
Level

<tbody>
</tbody>
2.1.2 A

<tbody>
</tbody>
2.1.2 B

<tbody>
</tbody>
2.1.2. C

<tbody>
</tbody>
JOHN SMITH

<tbody>
</tbody>
10/03/2018

<tbody>
</tbody>
1TRUETRUEFALSE
JOHN SMITH

<tbody>
</tbody>
10/03/2018

<tbody>
</tbody>
2FALSEFALSETRUE

<tbody>
</tbody>

Is this even possible or am I way up the wrong tree?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top