+ Reply to Thread
Results 1 to 9 of 9

Locate Specific Text and Delete the Entire Row

  1. #1
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Locate Specific Text and Delete the Entire Row

    Hello,

    I have a macro written where the process works except for my last few steps, what I would like to do at the end is locate any of the following strings (please note these digits are imbedded in a longer number string - ex. 12-300-22000-5678 in Column V and delete the entire row once found....
    22000
    22005
    22025
    60-

    Here is my macro

    Please Login or Register  to view this content.
    Thank you very much
    Last edited by leebird; 12-01-2015 at 01:19 AM. Reason: Attachment Added

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Locate Specific Text and Delete the Entire Row

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Locate Specific Text and Delete the Entire Row

    @leebird
    As, I assume, you noticed in walruseggman's code, selecting is very seldom required and it slows down the macro as well.
    Your "Cells.Select" selects 17,179,869,184 Cells (1,048,576 Rows x 16,384 Columns)
    Looking at your code, youre not working with 17+ million cells.
    Similar for the "Columns("M:M").Select". Here you select 1,048,576 Cells. Hardly required by the looks of it.
    There are lots of ways to work with only the "used cells".
    For a Column, one of the possibilities would be
    Range("M1:M" & Cells(Rows.Count, "M").End(xlUp).Row)

    Just for practice purposes, put the following code in a regular Module and see what the result is.

    Please Login or Register  to view this content.
    You'll notice that it only selects from M1 to the last used Cell in Column M

    If you use the method in your code for formatting you'll see that the size of your workbook will be very big after saving and that it will get slower and slower.
    If you would Google "Excel File Size Increased" or "Bloating Excel Files" or something similar you'll find some examples of this.

    Just some friendly pointers. No negative intentions at all. We all started out this way
    I feel generous today. After all, our local football team got the cup yesterday.
    If you have any questions that will make your Excel life easier, make sure to come back here and someone will help you.

  4. #4
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Re: Locate Specific Text and Delete the Entire Row

    Test.xlsm

    Hello,

    Hmmm I don't seem to be having any luck. I have added a sample attachment. Ideally I'm hoping to go through column M and replace the empty cells with the text "No Description" next, go to column W and replace the empty cells with the text "Delete", next search for duplicates in column V and delete those rows, next search through column V for cells that contain (20000, 22005, 22025, 22000 and 60-)and
    delete those rows, last autofit the whole page.

    Sorry, my original macro does seem long, still working through the shortcuts

    Thanks so much

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Locate Specific Text and Delete the Entire Row

    Try
    Please Login or Register  to view this content.

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Locate Specific Text and Delete the Entire Row

    Don't know how much data (number of rows) you have in the file as I assume the upload is a small sample. If so I think I would start getting rid of duplicates and rows that contains "60-", "2200" and so fort in order to reduce the number of rows to check for blank values in column M and V.

    So adding a few bits and pieces to jindons's code you could try this:

    Please Login or Register  to view this content.
    Alf

  7. #7
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Re: Locate Specific Text and Delete the Entire Row

    This worked great! Thank you very much. Wonderful macro.

  8. #8
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Re: Locate Specific Text and Delete the Entire Row

    Thank you very much! I can definately re-use this code in another project I'm working on.

  9. #9
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Locate Specific Text and Delete the Entire Row

    You are welcome and thanks for feedback.

    Alf

+ 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 entire row for specific words
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-01-2015, 07:43 PM
  2. [SOLVED] How to locate specific text within a cell, starting from the right
    By SimplySA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2014, 04:27 AM
  3. [SOLVED] Locate column with specific title and delete rows if predefined set of text is found
    By johnny_tc in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-25-2012, 01:57 PM
  4. [SOLVED] Macro: Locate specific text within supplied range
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2012, 01:03 PM
  5. Locate a reference in a table based on specific words on a text
    By zetavares83 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-06-2012, 06:17 PM
  6. Locate row above cell with specific text, and apply formatting?
    By HelenW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2009, 11:09 AM
  7. Locate and delete specific cells
    By David Smith in forum Excel General
    Replies: 1
    Last Post: 01-19-2005, 01:06 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