+ Reply to Thread
Results 1 to 3 of 3

Macro to copy cell from the next column if a certain word is found

Hybrid View

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    69

    Macro to copy cell from the next column if a certain word is found

    Hi,

    I'm trying to find a macro that goes through all the rows to see if a cell from Column Z has the word "*other", if so it'll copy the cell next to it in Column AA and replace the original "*other" in Column Z with the copied cell. Otherwise, it would continue to the next row. I've attached a before and after xlsx to give an example of what I'm looking for.

    before.xlsx
    after.xlsx

    Any help would be appreciated. Please let me know if I need to clarify anything.

    Thanks.

  2. #2
    Registered User
    Join Date
    01-15-2016
    Location
    Dallas, TX
    MS-Off Ver
    2007
    Posts
    65

    Re: Macro to copy cell from the next column if a certain word is found

    Try this, but note, it's not column Z in your workbooks that has the "*other", but rather column AA1... so you may have to adjust the range to suit.

    Sub Other()
    Dim lrow As Long
    Dim rng As Range
    
    lrow = ActiveSheet.UsedRange.Rows.Count
    Set rng = Range("AA1", "AA" & lrow)
    
    For Each Cell In rng
    If Cell.Value = "*other" Then
    Cell.Value = Cell.Offset(0, 1).Value
    End If
    Next Cell
    End Sub
    If it works for you, I would appreciate some reputation (little black star on the left)

  3. #3
    Registered User
    Join Date
    03-21-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    69

    Re: Macro to copy cell from the next column if a certain word is found

    Quote Originally Posted by Raymundus View Post
    Try this, but note, it's not column Z in your workbooks that has the "*other", but rather column AA1... so you may have to adjust the range to suit.

    Sub Other()
    Dim lrow As Long
    Dim rng As Range
    
    lrow = ActiveSheet.UsedRange.Rows.Count
    Set rng = Range("AA1", "AA" & lrow)
    
    For Each Cell In rng
    If Cell.Value = "*other" Then
    Cell.Value = Cell.Offset(0, 1).Value
    End If
    Next Cell
    End Sub
    If it works for you, I would appreciate some reputation (little black star on the left)
    Ah, you're right, I mistakenly copied it into the wrong column. I've adjusted the range to column Z and it worked perfectly! Thank you very much! Repped!

+ 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. Need macro to search for key word in column and then run another macro if found
    By Atorado in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2015, 11:25 PM
  2. UDF to return one of each word found in a column to a single cell on another sheet
    By Doing my best in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2014, 12:12 PM
  3. [SOLVED] looking to find 1 of 2 words in a cell in column B and return the word found in the same
    By Rob69mfj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-27-2014, 01:17 PM
  4. Is a Macro going to be the best way to copy Column range if value cell D87 is found
    By extremecorvette in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2011, 12:00 PM
  5. Macro for searching for a Word and If found append some more data steps to that cell
    By teja32@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2011, 06:42 AM
  6. Replies: 6
    Last Post: 10-15-2009, 10:33 AM
  7. Macro to Search column and if found, copy a cell within the worksheet
    By SKooT1027 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2008, 01:12 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