+ Reply to Thread
Results 1 to 7 of 7

Issue with Macro Code to Search via InputBox and Hide

  1. #1
    Registered User
    Join Date
    05-21-2017
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2016
    Posts
    13

    Issue with Macro Code to Search via InputBox and Hide

    Greetings,

    I'm looking to create a macro that will search column F for a specific value (e.g. 1700-0100), and then hide every row where it locates that particular value in that column. The following code is what I have so far - but once I click 'OK' on the Inputbox, the spreadsheet freezes and is forever thinking - and I inevitably have to close down the spreadsheet to continue working. The code is as follows;

    Please Login or Register  to view this content.
    Would anyone have any ideas on what is wrong with the above code, and/or a solution to alleviate the symptoms I described? Attached is a sample of the worksheet that the macro will be on.

    All help is appreciated, and many thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Issue with Macro Code to Search via InputBox and Hide

    Try

    Set SrchRng = ActiveSheet.Range("F1", ActiveSheet.Range("F65536").End(xlUp))
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    05-21-2017
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2016
    Posts
    13

    Re: Issue with Macro Code to Search via InputBox and Hide

    Thanks for the quick reply kev. While the change you suggested did hide the values I searched for, it still appeared to be continuing to search - and Excel ended up 'not-responding' as before. I tried this on several computers for the same outcome...

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Issue with Macro Code to Search via InputBox and Hide

    Try this one.

    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.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Issue with Macro Code to Search via InputBox and Hide

    Hi Reimertoad

    Try using AutoFilter...
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  6. #6
    Registered User
    Join Date
    05-21-2017
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2016
    Posts
    13

    Re: Issue with Macro Code to Search via InputBox and Hide

    Thank you all very much for your help! I've decided to run with bakerman2's option as it's working a treat and perfect for what's required. Thanks again and I appreciate your quick responses.

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Issue with Macro Code to Search via InputBox and Hide

    For the sake of completeness, the problem with the original code was:
    Repeated use of Find with no change in parameters. You started from the top every time and just kept finding the first instance over and over.
    The FIX: use Find once. If it works, save the address, then loop using FindNext with previous result as starting point. Exit when first is found again.
    NOTE: This works because FindNext wraps around to the top of the column when it reaches bottom. This allows you to start searching from any position in the range.
    Please Login or Register  to view this content.
    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 05-28-2017 at 08:44 PM.

+ 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] Macro to search several columns and then hide the row
    By pmeise in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-17-2016, 04:57 PM
  2. [SOLVED] MACRO: If user clicks cancel in inputbox,then do nothing. Problem with inputbox appearance
    By Tona in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-05-2015, 04:33 AM
  3. [SOLVED] Urgent: Please help with application.inputbox issue
    By corey.dusin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2014, 03:13 PM
  4. [SOLVED] InputBox issue
    By VanniFucci in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-01-2013, 06:17 AM
  5. [SOLVED] Inputbox to search a value
    By stoven in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-18-2012, 06:53 PM
  6. [SOLVED] Macro ignores search code when 1 of the 2 search parameters is not found
    By BrodyNoochie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2012, 05:21 PM
  7. [SOLVED] Search for Value from InputBox
    By Tempy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-14-2005, 05: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