+ Reply to Thread
Results 1 to 11 of 11

Finding words and copying adjacent cell

Hybrid View

  1. #1
    Registered User
    Join Date
    05-04-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2011 OSX Home, Excel 2010 Home, Excel 2002 SP3 Work
    Posts
    29

    Finding words and copying adjacent cell

    Hi,

    I need some help with a formula. I have a sheet1 with a bunch of data and I want my sheet2 to find a specific cell in sheet1 if that row in sheet1 contains a word. For example: If the word "red apple" can be found somewhere in column A in sheet1, then take that row containing "red apple" and its value in column B and copy it to cell A2 in sheet2.The problem is that there can be a "green apple", "blue banana" and a bunch of other words, that is why the formula needs to search for a specific combination of words (I used A1&" "&B1 where A1 is color and B1 is fruit). When the formula finds a word, it should take the value in an adjacent cell in the same sheet and copy it to another sheet.
    Last edited by Ranew; 05-09-2011 at 10:31 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Finding words and copying adjacent cell

    Hi,

    I think VLOOKUP should do the trick but can you upload a sample workbook showing your data layout and desired result.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    05-04-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2011 OSX Home, Excel 2010 Home, Excel 2002 SP3 Work
    Posts
    29

    Re: Finding words and copying adjacent cell

    Quote Originally Posted by Domski View Post
    Hi,

    I think VLOOKUP should do the trick but can you upload a sample workbook showing your data layout and desired result.

    Dom
    Here is an example of what I am trying to do. The real file contains alot more data. I want C2 and C3 in UI-sheet to be filled with data from Data-sheet. I have a drop down menu for fruit and color. If I pick "red" as color and "apple" as fruit, I want C2 and C3 in UI-sheet to be 4 and Yes.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-04-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2011 OSX Home, Excel 2010 Home, Excel 2002 SP3 Work
    Posts
    29

    Re: Finding words and copying adjacent cell

    I tried the VLOOKUP but I didn't know how to copy the values in the adjacent cells.

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Finding words and copying adjacent cell

    Try this:

    For Number: =VLOOKUP(A2&" "&C1,Data!$A$1:$C$8,2,FALSE)
    For Yes/No: =VLOOKUP(A2&" "&C1,Data!$A$1:$C$8,3,FALSE)

    Dom

  6. #6
    Registered User
    Join Date
    05-04-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2011 OSX Home, Excel 2010 Home, Excel 2002 SP3 Work
    Posts
    29

    Re: Finding words and copying adjacent cell

    Works great! Thank you so much!

  7. #7
    Registered User
    Join Date
    05-04-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2011 OSX Home, Excel 2010 Home, Excel 2002 SP3 Work
    Posts
    29

    Re: Finding words and copying adjacent cell

    Your formula works great, the only problem is that it returns #N/A if there are no yellow apples. I managed to write this formula to remove the #N/A, but now it returns a 0 if a yellow apple is found, but with no numer or Yes/No.

    =IF(ISERROR(VLOOKUP($C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE));"";VLOOKUP($C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE))

    I need a formula that returns blank for either an error (#N/A) or an empty cell.

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Finding words and copying adjacent cell

    =IF(OR(ISERROR(VLOOKUP($C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE)),VLOOKUP($C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE)=0);"";VLOOKUP($C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE))

    Dom

  9. #9
    Registered User
    Join Date
    05-04-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2011 OSX Home, Excel 2010 Home, Excel 2002 SP3 Work
    Posts
    29

    Re: Finding words and copying adjacent cell

    Now I get the #N/A error again when VLOOKUP does not find anything, strange...

    =IF(OR(ISERROR(VLOOKUP($C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE));VLOOKUP($C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE)="");"";VLOOKUP($C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE))

    I also changed the =0 to ="" since some values can actually be 0. I had a problem with VLOOKUP returning 0 when the cell was empty.

  10. #10
    Registered User
    Join Date
    05-04-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2011 OSX Home, Excel 2010 Home, Excel 2002 SP3 Work
    Posts
    29

    Re: Finding words and copying adjacent cell

    Did this instead, now it works:

    =IF(ISNA(VLOOKUP(C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE));"";VLOOKUP(C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE))

  11. #11
    Registered User
    Join Date
    05-04-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2011 OSX Home, Excel 2010 Home, Excel 2002 SP3 Work
    Posts
    29

    Re: Finding words and copying adjacent cell

    Okey, now I finally solved it;

    =IF(ISNA(VLOOKUP(C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE));"";IF(VLOOKUP(C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE)="";"";VLOOKUP(C$2&" "&$A$3;Data!$A$1:$O$200;5;FALSE)))

    It will return blank if it is #N/Aor an empty cell. I used IF(logic, false, (IF(logic, false, true))

+ 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