+ Reply to Thread
Results 1 to 11 of 11

Google Sheets: IF cell contains word X then add X to another cell BUT IF…

  1. #1
    Registered User
    Join Date
    10-07-2021
    Location
    Sweden
    MS-Off Ver
    Google Sheets
    Posts
    3

    Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    Hi.
    I just can not figure this out and I hope someone can help me.

    What I want to achieve is this:
    IF cell A1 contains word ”Sawlaskoup” THEN add word ”v1” to cell A2. BUT IF cell A1 contains word ”Ivac” THEN add word ”v2” to cell A2.
    Last edited by AliGW; 10-08-2021 at 04:34 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,418

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    Welcome to the forum.

    I don’t use Google Sheets, but in Excel it could be done like this (in A2):

    =IF(A1="Sawlaskoup","v1",IF(A1="Ivan","v2",""))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    10-07-2021
    Location
    Sweden
    MS-Off Ver
    Google Sheets
    Posts
    3

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    Hi, and thank you for your quick reply!
    It worked flawlessly! Huge thanks to you
    However, I just ran into a new problem. I want to be able to input other words to A2 aswell (without the code). Is it possible to make this code do its work from another cell like B1?

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,418

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    Clarify what you mean - give an example. If you mean you want a formula AND manual entry in one cell, then no, that’s probably not possible (it certainly isn’t in Excel).

  5. #5
    Registered User
    Join Date
    10-07-2021
    Location
    Sweden
    MS-Off Ver
    Google Sheets
    Posts
    3

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    The idea I had was if =IF(A1="Sawlaskoup","v1",IF(A1="Ivan","v2","")) could do its work from cell B2, instead of A2. That the code is written in cell B2 instead, but still only affects cell A2.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,418

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    No, that’s not possible (in Excel it would require VBA), unless A2 contained a formula (=B2).

    I suspect (but don’t know) that Google Sheets will behave similarly. Hopefully a Google Sheets aficionado can confirm.

  7. #7
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,147

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    As an Google Sheets alternative, i can offer something like shown in the picture below where the main formula is entered in cell A2 and the result is seen in cell B2;
    Attached Images Attached Images

  8. #8
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    @Haluk, there is no need for any array {curly brackets} .. as described by AligW does exactly the same thing in either excel or google sheets

  9. #9
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,147

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    @janmorris;

    I think you are missing the point.....

    The formula suggested by AliGW returns the result in the cell which houses the formula. But, in my alternative; the expected result (i.e., the second element of the result array) will be shown in the adjacent cell.



    I guess, something like this was required by the OP.
    Last edited by Haluk; 10-08-2021 at 04:23 PM.

  10. #10
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    @Haluk, no i dont think i am. i will be quite forward with my response to this... i use Google Sheets enough to know that unless the cell must be clear so that it can take values from somewhere else then it is a pointless suggestion.

  11. #11
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,147

    Re: Google Sheets: IF cell contains word X then add X to another cell BUT IF…

    So, what do you think that the OP is asking for in his message #5 ?

+ 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] Excel to Word: Select only Word cell's text and not the cell range
    By Menohavename in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-31-2020, 05:01 PM
  2. [SOLVED] Copying the first word from a cell and replacing another word from the same cell with it
    By spasoval in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-17-2017, 08:11 AM
  3. Replies: 6
    Last Post: 08-23-2013, 06:52 AM
  4. Check cell for word, If word exists in cell, assign that cell to corresponding category.
    By Trevasaurus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2012, 12:35 PM
  5. Replies: 8
    Last Post: 10-13-2012, 02:49 PM
  6. [SOLVED] How can I replace a word from a sentence in a cell & substitute word from another cell
    By rionoah in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-11-2012, 08:44 AM
  7. Replies: 6
    Last Post: 07-16-2009, 12:40 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