Thread: VBA copy issues
View Single Post
 
Old 05-03-2023, 08:04 PM
syl3786 syl3786 is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Jan 2023
Posts: 78
syl3786 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
Oops, my bad. I didn't read beyond your code.

Your code is finding a string from the list. When it finds that string, it appears you want to report that value (which you already had anyway). It would make more sense if it actually looked to the right of the found string to return the value of the text sitting beside that found string (or returned the contents of the whole paragraph).

Neither of the Excel workbooks look like they match the concept of list.xlsx. I was expecting a list of user names in that. Your code then loops through each list item finding hits before moving on to a next list item. This will harvest the data in unrelated order - for instance your outcome doc shows an order like
CEO, Oliver, CEO, Ethan, CEO, Amelia, ...
but your code is structured to return
CEO, CEO, CEO, ..., Oliver, Ethan, Amelia, ...
Why would that be a useful output?

I'm looking at the contents of the Word file and in my mind, aligning it with your outcome workbook and think perhaps the list and the search is a pointless distraction. To me it appears you want the dialog transferred in the correct order into Excel and separate the speaker from the dialog by putting each into two separate columns. If this is the case, what is the point of searching for list items unless you want to exclude specific speakers?

Your word doc shows xxx against each name. Your Excel workbook shows headings of Name & URL. Is each piece of text beside a name a URL or a string of text?
It is my bad. I posted the links of sample files after your first comment.
I also forgot to upload the Excel list as reference. I edited the post and comments again. You can now see the Excel list.

I expect the macro can copy the specific text such as "CEO", and other names (there should be more than 100 names but i just typed some of them in the sample) from Word to Excel according to the Excel List.

The URL column in the Excel template and Excel(expected outcome) is for putting URL and then mail merge those URLs to the displayed text by another macros. I already have that, but I am struggled in this macro (copying text from Word to Excel)

Word document for testing: Loading Google Docs

Excel template: Loading Google Sheets

Excel List: Loading Google Sheets

Excel file (Expected outcome): Loading Google Sheets
Reply With Quote