+ Reply to Thread
Results 1 to 6 of 6

macro to select a cell after performing a search (Attached)

  1. #1
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Smile macro to select a cell after performing a search (Attached)

    Would someone be kind enough to tell me how to mod the code below?
    I have also attached the workbook if it helps at all.

    The code below works fine if I enter a search term that resides in column C and run the macro, it then selects a cell in the column to the left B, on the same row so that I can enter a quantity.

    I have two problems:
    If I enter a search term that resides in column A the macro fails because it can’t select one cell to the left.
    Is it possible to make the resulting search select the cell in column B?
    Example: Search results in C4 and cell B4 is selected or Search results in A5 and B5 is selected.
    The auto selected cell should always be in column B

    Also, if I enter a search term on a word or letter that doesn’t exist, it fails.
    Example: There is no letter x in the ranges so searching on x would fail.
    Would it be possible to display a msg box saying not found, instead of the macro failing?

    In short...
    Search on column B and C, if the result is C7 or A7, then the macro would automatically select B7
    If a search term that doesn’t exist is entered into the search box, a message box opens displaying something like “Not Found”.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Mayweed; 09-01-2010 at 08:35 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: macro to select a cell after performing a search (Attached)

    Try assigning this to your button.
    Please Login or Register  to view this content.
    Assumes value will only be found once.

  3. #3
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: macro to select a cell after performing a search (Attached)

    Brilliant, Thank you Stephen it works perfectly.
    One more question if you don't mind; if the search term is found but there are more of the same (Apple1, Apple2 etc) would it be possible for the search box to display a Next" button so that you can move forward to the next match?

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: macro to select a cell after performing a search (Attached)

    Try this:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: macro to select a cell after performing a search (Attached)

    What can I say; your code works perfectly again; all problems solved within minutes.
    Your help is much appreciated Stephen, thanks again.

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: macro to select a cell after performing a search (Attached)

    My pleasure.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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