+ Reply to Thread
Results 1 to 11 of 11

Take no action when the search criteria is not found.

  1. #1
    Forum Contributor
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    109

    Take no action when the search criteria is not found.

    I use this macro to delete all the rows containing zero in the given column. Column K in this case.

    Please Login or Register  to view this content.
    It works fine and deletes the rows where there is a zero in K , leaving the rest of the data in place.

    Unfortunately , if it so happens that there are no zeros in the column, it wipes out all of the data in the sheet except the header.

    I wonder if there is a way to stop it doing this and leave everything intact in the absence of the search criteria.

    Grateful for any advice.
    Last edited by CaMeSuffit; 05-26-2025 at 11:44 PM.
    Using Access , Word and Excel 2003 in 2025

  2. #2
    Forum Contributor
    Join Date
    01-25-2025
    Location
    Presov, Slovakia
    MS-Off Ver
    2021
    Posts
    297

    Re: Take no action when the search criteria is not found.

    Hi CaMeSuffit,
    Please Login or Register  to view this content.
    m.s.

  3. #3
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,115

    Re: Take no action when the search criteria is not found.

    Hello CaMeSuffit,

    Try it as follows(just clearing all the "Selections"):-

    Please Login or Register  to view this content.
    I hope that this helps.

    Cheerio,
    vcoolio

  4. #4
    Forum Contributor
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    109

    Re: Take no action when the search criteria is not found.

    Thanks Guys! It's working fine now.

  5. #5
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,115

    Re: Take no action when the search criteria is not found.

    You're welcome. Glad we could help and thanks for the rep.

    Cheerio,
    vcoolio.

  6. #6
    Forum Contributor
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    109

    Re: Take no action when the search criteria is not found.

    Hi vcoolio - just wondering - could your code in post #3 be extended to report how many rows containing a zero in the chosen column were deleted?

    Just a simple popup message box giving quantity deleted would be great if possible.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,569

    Re: Take no action when the search criteria is not found.

    Try this.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,301

    Re: Take no action when the search criteria is not found.

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,115

    Re: Take no action when the search criteria is not found.

    Hello CaMeSuffit,

    Looks like Bakerman has done the task for us! That should complete your query.

    Cheerio,
    vcoolio.

  10. #10
    Forum Contributor
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    109

    Re: Take no action when the search criteria is not found.

    Thanks all.

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,569

    Re: Take no action when the search criteria is not found.

    You're welcome and thanks for rep+.

+ 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. Replies: 5
    Last Post: 09-01-2014, 08:05 AM
  2. Need help updating this macro to not fail when search criteria is not found.
    By programct in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-30-2013, 04:22 PM
  3. [SOLVED] Find text in more cells. If found do an action.
    By tepke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2013, 04:46 PM
  4. How to skip filter action if particular value is not found in record
    By shaikh_javed246 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-31-2012, 02:15 PM
  5. [SOLVED] INDEX-MATCH function return '0' if search criteria not found
    By Ben.SFM in forum Excel General
    Replies: 2
    Last Post: 04-27-2012, 01:46 PM
  6. If text found in list then complete action
    By CJ944 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2010, 08:38 AM
  7. Replies: 1
    Last Post: 10-05-2006, 05:56 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