+ Reply to Thread
Results 1 to 8 of 8

Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

  1. #1
    Registered User
    Join Date
    06-28-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    3

    Question Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

    I'm trying to write a macro that will look at a certain column range (column A) and find all cells with value "TEXT 1". For all those cells with value "TEXT 1", the macro should enter "TEXT 2" to the cell adjacent to it (to the right).

    Thanks,
    Madreag

  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: Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

    Hello madreag,

    Welcome to the Forum!

    Is there some reason you can not use a formula in the adjacent column to do this?
    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
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

    Hi,

    Do you really need a macro. Why not in B1 just
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

    Hi and welcome to the forum

    You dont need a macro for this, a simple IF() will do it for you

    assuming you want to start this in B2...

    =if(A2="Text1","Text2",A2)

    copied down
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    06-28-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

    Thanks for the welcome!

    We could use a formula, but I would like to keep it simple to the end user; it would be nice if all they had to do was run 1 macro.

    Also, I will be inserting this macro as part of a larger one.

    EDIT: I don't think we can use a formula since some adjacent cells are already filled or blank.
    Last edited by madreag; 06-28-2013 at 05:03 PM.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

    hmmm...run a macro....do nothing and the formula does what it is supposed to do....

    I would have thought the "do nothing and the formula does what it is supposed to do" would have been pretty simple?

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

    Quote Originally Posted by madreag View Post
    Thanks for the welcome!

    We could use a formula, but I would like to keep it simple to the end user; it would be nice if all they had to do was run 1 macro.

    Also, I will be inserting this macro as part of a larger one.
    In that case just encapsulate the formula in a macro. e.g.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-28-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Find "TEXT 1" in a range and enter "TEXT 2" in the adjacent cell

    Richard,
    your macro does the job, but it also clears all the other cells from column B. Is there a way to only affect the cells adjacent to TEXT 1?

    Maybe the best way to do this would be to do a find TEXT 1 macro and use .offset(,1) to change the adjacent cells only? How would I put this in a loop?

    something like this that loops?

    Please Login or Register  to view this content.

+ 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