+ Reply to Thread
Results 1 to 9 of 9

Populate Cell based on IF SEARCH() criteria in Different Cell

  1. #1
    Registered User
    Join Date
    10-04-2011
    Location
    Tennessee
    MS-Off Ver
    Excel 2010
    Posts
    6

    Populate Cell based on IF SEARCH() criteria in Different Cell

    First off, apologies if this is already a solved issue somewhere on the forum. This is my first time using the forum and I have not had luck finding this issue addressed in my search of it so far.

    My question is how to populate a cell if a value of another cell contains a specific text, and, if it does not, I want to populate a cell X columns from the one that contains the if statement.


    The logic i'm trying to capture is:

    if Col1R1 contains "J", then Col2R2=Col1R1, else Col4R2=Col1R1

    I've tried using offset(), but have not had luck.

    When I use if(search("Text",CellX,1),CellX,CellY=CellX) It does not recognize the else statement. I feel this should work (could be wrong) but I'm not able to solve thus far.

    Again apologies if there is a previous thread regarding this. Haven't been able to find it.
    Last edited by Human; 10-04-2011 at 03:42 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Populate Cell based on IF SEARCH() criteria in Different Cell

    if Col1R1 contains "J", then Col2R2=Col1R1, else Col4R2=Col1R1


    You need two IF Statements, one in Col2R2 and one in Col4R2

    B2 - Col2R2: =IF(A1="J", A1,"")
    D2 - Col4R2: =IF(A1<>"J",A1,"")


    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-04-2011
    Location
    Tennessee
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Populate Cell based on IF SEARCH() criteria in Different Cell

    Thanks for the reply! I actually need this to be in one formula so I can drag it across the sheet. currently I have in cell H8 =if(search("X",B3,1), B3, N8=B3)

    When I change the value_if_false parameter to a text result like "Boo", it does work, with the current N8=B3 it only returns "FALSE" in cell H8.

    I've never tried to define a cell value in an if statement like N8=B3, so I'm probably making an ignorant error there in the first place.

    Good news is the calculation does go to the Else statement when I put "Boo" as the value_if_false so I'm isolating the error.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Populate Cell based on IF SEARCH() criteria in Different Cell

    Quote Originally Posted by Human View Post
    ...currently I have in cell H8 =if(search("X",B3,1), B3, N8=B3)

    ...I've never tried to define a cell value in an if statement like N8=B3, so I'm probably making an ignorant error there in the first place.
    Expressions 101: A formula returns a single value, which is displayed in the cell containing the formula. A formula cannot cause a value to appear in some other cell. It look like you are trying to say that when the IF condition is FALSE, then put the value from B3 into N8. But what Excel does is to evaluate the expression "N8=B3", which it does by comparing the values of the two cells. This is a comparison, not an assignment. The two cells are not equal, so the result is FALSE.

    If you want a value in one cell under one condition, and a value in a different cell under a different condition, then you need a formula in each of the target cells, as shown by TMShucks.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Registered User
    Join Date
    10-04-2011
    Location
    Tennessee
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Populate Cell based on IF SEARCH() criteria in Different Cell

    Right, it's still an evaluation and boolean.
    Last edited by Human; 10-08-2011 at 09:41 PM.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Populate Cell based on IF SEARCH() criteria in Different Cell

    You may wish to mark this thread as Solved. I guess it's not the answer you want but it's the best you're going to get.

    Regards

  7. #7
    Registered User
    Join Date
    10-04-2011
    Location
    Tennessee
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Populate Cell based on IF SEARCH() criteria in Different Cell

    I already marked as solved after the response from 6StringJazzer. Is it not showing this way?

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Populate Cell based on IF SEARCH() criteria in Different Cell

    Yes, sorry ... just me not noticing

  9. #9
    Registered User
    Join Date
    10-04-2011
    Location
    Tennessee
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Populate Cell based on IF SEARCH() criteria in Different Cell

    just making sure.
    Last edited by Human; 10-08-2011 at 09:40 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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