+ Reply to Thread
Results 1 to 2 of 2

Search for and extract word from a cell

Hybrid View

  1. #1
    Registered User
    Join Date
    12-27-2007
    Posts
    5

    Smile Search for and extract word from a cell

    How would you write VBA code that would search a cell (containing words and numbers) for a particular word, pull that word out of the cell and place it into the next column over?

    Example:

    Cell contains the string "Happy New Year 2008 Be safe and have fun 03010"

    How would I pull out the word "Year" and put it into the next column and leave everything else in the cell?

    Thanks!

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Try

    Sub Test()
    For Each Cell In Selection
        If InStr(Cell, "Year") <> 0 Then Cell.Offset(0, 1) = "Year"
    Next Cell
    End Sub
    Martin

+ 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