+ Reply to Thread
Results 1 to 6 of 6

Delete Lines in all Workbook in Folder that contain certain strings

  1. #1
    Forum Contributor
    Join Date
    05-24-2020
    Location
    London
    MS-Off Ver
    Office 365 pro
    Posts
    177

    Delete Lines in all Workbook in Folder that contain certain strings

    Hello together,
    I would like to delete in all workbooks in a folder, no matter if it is formatted xlsm, xlsx, xls etc, all lines that contain a certain sentence or word.
    I would like to enter this sentence or word or character combination with an inputbox and select the folder via popup.

    Thank you very much for your help.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,833

    Re: Delete Lines in all Workbook in Folder that contain certain strings

    Do you want to search all the sheets in all workbooks? Is the word or sentence in one particular column or can it be anywhere in the sheet? It would be easier to help and test possible solutions if you could attach a copy of one or two of your files. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    05-24-2020
    Location
    London
    MS-Off Ver
    Office 365 pro
    Posts
    177

    Re: Delete Lines in all Workbook in Folder that contain certain strings

    Hi Mumps1
    I am glad that you are taking care of my problem.
    I would have to search all the sheets in all the workbooks because the text can be anywhere.
    But the text is always exactly the same.

    It is always in Column 1 but the row varies.

    For this reason it makes no sense to upload a workbook.

    I can do it though if you want.
    Thanks again very much
    Last edited by CoSinus; 12-29-2020 at 11:17 AM.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,833

    Re: Delete Lines in all Workbook in Folder that contain certain strings

    It would be easier to test a possible solution if you attach one or two workbooks. Give a few examples of a word or sentence you would like to search. Also, can there be duplicate words or sentences in column A?

  5. #5
    Forum Contributor
    Join Date
    05-24-2020
    Location
    London
    MS-Off Ver
    Office 365 pro
    Posts
    177

    Re: Delete Lines in all Workbook in Folder that contain certain strings

    It took a while and I apologize for the delay.

    In the last labeled line of many sheety is invisible Text 'End of Worksheet'.
    In addition, in some sheets there are sentences like: 'Selections are indicated using an "X".' which I would like to delete.

    The invisible text contents occur in different forms.
    But it is always column A in which all texts occur.

    I would like to delete flexibly by input box rows any sheet in a folder I would like to select by entering flexible contents I can write into the input box.

    Thank you for your help.
    Attached Files Attached Files

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,833

    Re: Delete Lines in all Workbook in Folder that contain certain strings

    Open a new blank workbook and copy/paste this macro into a regular module. The macro will prompt you to enter a text to search. Any row containing that text in column A will be deleted. For example, if you enter the text 'Selections', any row containing that word will be deleted meaning that the row containing 'Selections are indicated using an "X".' will be deleted but so will any other row containing 'Selections'. The reason for this is that the macro will also look for a partial match. If you want the search to be an exact match, then change the text in the code (in red) to 'xlwhole'. Also, the source files will be saved and then closed, replacing the previous versions, after the rows are deleted. See the row in blue.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Delete empty lines in textbox but keep existing lines.
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-25-2020, 09:39 PM
  2. [SOLVED] Loop through lines in a text file ignoring lines between two different strings
    By webwyzard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2018, 08:00 PM
  3. [SOLVED] Black strings (lines) over corner of cells
    By grouseuk in forum Excel General
    Replies: 3
    Last Post: 09-20-2018, 12:01 PM
  4. [SOLVED] Loop and delete lines till no more lines left to check
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2018, 08:15 AM
  5. Macro to Delete only Alpha Strings but not Alphanumeric or Numeric Strings in a Cell
    By papageorgio in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2016, 06:55 AM
  6. [SOLVED] Macro neede to open text files from folder and remove all the lines except specific lines
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-07-2014, 02:44 AM
  7. [SOLVED] Macro to Delete useless lines, rearrange by dates and skip lines between different days.
    By Tmc2159 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-12-2012, 02:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1