+ Reply to Thread
Results 1 to 4 of 4

Search a range for cells that have values and set value in another cell based on results

  1. #1
    Registered User
    Join Date
    12-03-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Search a range for cells that have values and set value in another cell based on results

    I am looking for a macro that will search specified ranges on two work sheets and set a value in the cell immediately to the right for any matches found. All the search needs to do is search the specified range for any values, I am only interested in whether there is a value entered or not. I have attached an example file. What the macro should do is search the ranges "Bin_Codes" and "Bin_Codes2" and if any cells have data in them, it will enter the letter "D" in the adjacent cell to the right.

    Search via macro.xlsx

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Search a range for cells that have values and set value in another cell based on resul

    Hello catsup,

    In cell D3 enter this formula =IF(C3<>"","D","")
    Select cells D3 through D38 and press the keys CTRL D. This will automatically fill the cells with the formula.

    In cell I3 enter the formula =IF(I3<>"","D","")
    Select cells I3 through I38 and press the keys CTRL D. This will automatically fill the cells with the formula.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-03-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Search a range for cells that have values and set value in another cell based on resul

    Quote Originally Posted by Leith Ross View Post
    Hello catsup,

    In cell D3 enter this formula =IF(C3<>"","D","")
    Select cells D3 through D38 and press the keys CTRL D. This will automatically fill the cells with the formula.

    In cell I3 enter the formula =IF(I3<>"","D","")
    Select cells I3 through I38 and press the keys CTRL D. This will automatically fill the cells with the formula.
    Sorry, I should have specified, the reason I want it to be a macro is I will need to export the sheet to another program and only once it is exported do I want to fill in the adjacent cells. That is why I was thinking to use a macro. I won't be the one using the file either, so I would like to make it as simple as hitting the shortcut for the macro and having it do the necessary actions as there will be varying levels of excel knowledge among the users. Thanks for the help.

  4. #4
    Registered User
    Join Date
    12-03-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Search a range for cells that have values and set value in another cell based on resul

    I found the following code and modified to to apply to my range "Bin_Codes" I am not sure how to, or if it can be, modified to search for "*" instead of blank cells and then enter text in an offset cell instead of the matching cell.
    Please Login or Register  to view this content.
    Edit, I was able to figure it out. Code is as follows:

    Please Login or Register  to view this content.
    Last edited by Catsup; 01-25-2013 at 06:04 PM. Reason: Solved

+ 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