Any Word experts around?

Jon_01
Jon_01 Posts: 5,911 Forumite
Part of the Furniture 1,000 Posts Name Dropper
edited 4 November 2024 at 5:22PM in Techie Stuff

I've been sent a list of items. Each item ends with a code in the format (XXX..) 123..., because of this when I try to import it into my system it errors as the code isn't needed (bad programming, I know). The code string is a variable length.

The list looks like this 'Item Thing (xy-z) ab123'   I need to remove the leading ( and everything after it on the line.

Is there some way to use search and replace to remove the code and everything after it on the line?

I was thinking of something like 'search (*' and then Replace with . But that just throws up a Word error, 'No results found'!

I'm using Word Pro Plus 2019


«1

Comments

  • It’s possible to create a table from text in Word, where the column breaks are determined by a specific character. I don’t know if that works in your version of Word as I use a different one. Once you have the data in columns it’s easier to delete specific sections of strings. If you don’t want your data in a table you can replace your deleted text with a new character and then ‘find > replace’ to substitute a tab.
    Fashion on the Ration
    2024 - 43/66 coupons used, carry forward 23
    2025 - 60.5/89
  • born_again
    born_again Posts: 19,235 Forumite
    10,000 Posts Fifth Anniversary Name Dropper
    What format is the file?
    Life in the slow lane
  • Thinking along the lines as born_again I think regarding file import!!

    However the find and replace ( rather than "search") is most flexible when done in Word VBA (but shaort of time just at the mo!

    Far easier if it is a text or CSV file (or to save it as such) to import it into Excel (setting appropriate delimiters) which will put it all into columns and then just delete all the columns including "(" and after.

    [maybe can be imported similarly into word and also delete the columns??? nt something I am familiar with in the later versions of Word...]
  • GDB2222
    GDB2222 Posts: 25,913 Forumite
    Part of the Furniture 10,000 Posts Photogenic Name Dropper
    For future reference, this is the sort of problem that ChatGPT is good at solving. Particularly as you can show it a sample of real data. It’s very good at making short programs, if you want to start learning to program.


    No reliance should be placed on the above! Absolutely none, do you hear?
  • 400ixl
    400ixl Posts: 4,485 Forumite
    1,000 Posts Third Anniversary Name Dropper
    edited 4 November 2024 at 7:52PM
    Convert to table with ( as a delimiter is probably the quickest way. Then just copy the text from the column you want to keep and paste as keeping the text only.

    Should take les than a minute and no messing with VBA or anything.

    If it is a CSV file, then do it in Excel through import data.
  • Vitor
    Vitor Posts: 395 Forumite
    100 Posts First Anniversary Photogenic Name Dropper

    To remove everything starting from the first opening parenthesis ( and everything after it, you can use Word's Find and Replace feature with wildcards enabled. Here's how to do it:

    1. Open the Find and Replace dialog:

      • Press Ctrl + H to open the Find and Replace dialog box.
    2. Enable wildcards:

      • Click on More (if not already expanded).
      • Check the box labeled Use wildcards.
    3. Set up the search pattern:

      • In the Find what box, enter \(.*$
        • Explanation:
          • \( matches the literal opening parenthesis (.
          • .* matches any characters (zero or more times) until the end of the line.
          • $ matches the end of the line.
      • Leave the Replace with box empty to remove everything matched.
    4. Run the replacement:

      • Click Replace All.
  • Jon_01
    Jon_01 Posts: 5,911 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    edited 5 November 2024 at 11:52AM
    Vitor said:

    To remove everything starting from the first opening parenthesis ( and everything after it, you can use Word's Find and Replace feature with wildcards enabled. Here's how to do it:

    1. Open the Find and Replace dialog:

      • Press Ctrl + H to open the Find and Replace dialog box.
    2. Enable wildcards:

      • Click on More (if not already expanded).
      • Check the box labeled Use wildcards.
    3. Set up the search pattern:

      • In the Find what box, enter \(.*$
        • Explanation:
          • \( matches the literal opening parenthesis (.
          • .* matches any characters (zero or more times) until the end of the line.
          • $ matches the end of the line.
      • Leave the Replace with box empty to remove everything matched.
    4. Run the replacement:

      • Click Replace All.

    Thank you for that. .. But, I've followed it step by step, tried cut and pasting it and entering it and all I get is 'No Results Found'?

  • Heedtheadvice
    Heedtheadvice Posts: 2,719 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    edited 5 November 2024 at 1:11PM
    Might be the version of word you are using.  Certainly Find and Reaplace has improved over the years
    My old version would not accept the above method.
    However if yours is not producing an error message ( rather than not finding the search string ) it suggests something there does not match but that could still be the interpretation of the search string.
    Not sure of the versions Vitors solution works with, maybe you will get a post to let you know. You can always use 365 ( for free ) if your version is not recent.

    Further the use of a backslash can sometimes  be problematic ( no idea why!) but the best info I have ever found regarding Find is on a website that might  be useful to read at

  • Cornucopia
    Cornucopia Posts: 16,432 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    edited 5 November 2024 at 1:10PM
    Use find & replace to change "(" to "^t" (tab).   This has worked since the very early versions of Word.

    You can then change your text to a table and Word should split the lines at the Tab mark.
  • Any reason why you aren't doing this in Excel?
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 349.6K Banking & Borrowing
  • 252.5K Reduce Debt & Boost Income
  • 452.9K Spending & Discounts
  • 242.5K Work, Benefits & Business
  • 619.2K Mortgages, Homes & Bills
  • 176.3K Life & Family
  • 255.4K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 15.1K Coronavirus Support Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.