Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-25-2023, 07:53 AM
FMH FMH is offline How to delete 2nd nonsequential occurrence of item to end of document Mac OS X How to delete 2nd nonsequential occurrence of item to end of document Office 2019
Novice
How to delete 2nd nonsequential occurrence of item to end of document
 
Join Date: May 2023
Posts: 2
FMH is on a distinguished road
Default How to delete 2nd nonsequential occurrence of item to end of document

I have a list of Spanish words followed by a paragraph mark, followed by its translation, followed by another Spanish word and another paragraph mark. I want to delete every paragraph mark that follows a Spanish word or phrase and replace it with a tab and then continue that same process to the end of the file. It's a list of a thousand words. Here's an excerpt:

la televisión[prg mark]
television[prg mark]
amar[prg mark]
to love[prg mark]
el/la bebé[prg mark]
baby[prg mark]
regular[prg mark]
regular[prg mark]
describir[prg mark]
to describe[prg mark]


la dieta[prg mark]
diet[prg mark]
la banda[prg mark]
band[prg mark]

I want to repeat that delete-and-replace all the way to the end of the file. Anyone have a clue how I can achieve that? I've searched for macros online and 1) they might as well be written in Greek and 2) they never address this particular thing.
Reply With Quote
  #2  
Old 05-25-2023, 11:38 AM
kilroyscarnival kilroyscarnival is offline How to delete 2nd nonsequential occurrence of item to end of document Windows 10 How to delete 2nd nonsequential occurrence of item to end of document Office 2021
Expert
 
Join Date: May 2019
Posts: 344
kilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nice
Default

I can't think of an easy way to do this entirely in Word, but if you also have Excel:

Open a blank Excel worksheet.
Starting in cell A2, type an A, then enter. Type a B in A3, another A in A4, and another B in A5. Then select those ABAB cells and grab the fill handle and fill down to a couple of thousand rows. You'll want those for filtering.

Then, copy your text in Word and paste into the Excel sheet starting in cell B2. While it's still copied to your clipboard, ALSO paste it a second time starting in cell C3. You should now have the Spanish entry and the English entry side-by-side.

Select the whole area including your A "helper" column with the A's and B's, and activate a filter (Data/Filter). Select "B" in the A column, and those should have the rows that start with the English word and have the next Spanish word next to them. Delete these rows, and clear the filter.

Copy the Excel contents (without the A column, as you don't need those "A"s any longer, and paste into Word. It should automatically paste as a table; you can then go to the Layout section of the ribbon and Convert table to text, using a tab as the "separate with" between columns.

I'm sure there's a simpler way, but that works.
Reply With Quote
  #3  
Old 05-25-2023, 05:59 PM
Guessed's Avatar
Guessed Guessed is offline How to delete 2nd nonsequential occurrence of item to end of document Windows 10 How to delete 2nd nonsequential occurrence of item to end of document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Is there a specific style or language setting applied to either the spanish or english text so that they are spell checked with the right dictionary? This would be something that we could use to code the macro.

If you post a sample document then we might be able to work out a pattern that could be used for the macro.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 05-25-2023, 07:18 PM
FMH FMH is offline How to delete 2nd nonsequential occurrence of item to end of document Mac OS X How to delete 2nd nonsequential occurrence of item to end of document Office 2019
Novice
How to delete 2nd nonsequential occurrence of item to end of document
 
Join Date: May 2023
Posts: 2
FMH is on a distinguished road
Smile Wow. Just wow.

That was brilliant! I can't thank you enough. I never would have thought to create the first column--ABAB--and without it the problem wouldn't have been any easier in Excel than it was in Word. You save me a lot of tedious work.
Reply With Quote
  #5  
Old 05-25-2023, 07:28 PM
Guessed's Avatar
Guessed Guessed is offline How to delete 2nd nonsequential occurrence of item to end of document Windows 10 How to delete 2nd nonsequential occurrence of item to end of document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If the entire document is pairs of spanish/english then I would stay in Word and select it all and convert Text to Table, specify 2 columns and Paragraph mark as the separator.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #6  
Old 05-25-2023, 07:59 PM
Guessed's Avatar
Guessed Guessed is offline How to delete 2nd nonsequential occurrence of item to end of document Windows 10 How to delete 2nd nonsequential occurrence of item to end of document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

And once it is a table it can be converted back to text which puts in the tab marks
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 05-26-2023, 07:32 AM
kilroyscarnival kilroyscarnival is offline How to delete 2nd nonsequential occurrence of item to end of document Windows 10 How to delete 2nd nonsequential occurrence of item to end of document Office 2021
Expert
 
Join Date: May 2019
Posts: 344
kilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nice
Default

Wow, Andrew, I never thought of that! It works more simply than my version.
I've just had to do that in Excel before, and not in Word.

See, FMH, I knew there had to be a better way, but also knew my way would work. Now both of us learned something.
Reply With Quote
Reply

Tags
delete 2nd occurrence

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete 2nd nonsequential occurrence of item to end of document Searching a Word document with multiple words from a list (over 1,000 terms) and BOLD all occurrence Nicknamednick Word 9 09-28-2022 05:41 PM
How to delete 2nd nonsequential occurrence of item to end of document Highlight every occurrence of ... eduzs Word VBA 7 06-27-2020 12:58 PM
How to delete 2nd nonsequential occurrence of item to end of document Copying data related to one item to worksheet with many instances of the same item nmp13 Excel 3 02-06-2016 02:13 AM
How do I delete an Outlook appointment item with VBA? Joe Patrick Outlook 0 07-14-2011 06:56 AM
How to Delete Outlook Item with VBA Joe Patrick Outlook 0 07-14-2011 06:49 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft