+ Reply to Thread
Results 1 to 3 of 3

Find Word and set cell where found

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Find Word and set cell where found

    I want a macro to look in column A for the word Timer. It can be any case and the word timer could be in a sentence. Once it is found I want to set the cell where it is found so I can copy that cell.

  2. #2
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Find Word and set cell where found

    I have the below which now finds the word I want. However, the formula I am then trying to insert - it actually uses the word Found instead of the range where it is actually found. Any help with that bit?
    Sub NextPart()
    With Sheets("Macro")
    Dim FindWord As String, Found As Range
    
    FindWord = "Time "
    
    Set Found = Sheets("Macro").Columns("A:A").Find(What:=FindWord, _
                                                LookIn:=xlValues, _
                                                LookAt:=xlPart, _
                                                SearchOrder:=xlByRows, _
                                                SearchDirection:=xlNext, _
                                                MatchCase:=False)
                                            
        If Not Found Is Nothing Then
            Found.Select
        Else
            MsgBox "No match found."
        End If
       
    End With
    
    With Sheets("Macro")
        Found.Offset(0, 1).Formula = "=MID(Found,SEARCH(""Time"",Found)+5,8)"
          
    End With
    
    End Sub

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Find Word and set cell where found

    simply
    Sub NextPart()
          Dim FindWord As String, Found As Range
    
          FindWord = "Time "
    
          Set Found = Sheets("Macro").Columns("A:A").Find(What:=FindWord, _
                                                          LookIn:=xlValues, _
                                                          LookAt:=xlPart, _
                                                          SearchOrder:=xlByRows, _
                                                          SearchDirection:=xlNext, _
                                                          MatchCase:=False)
    
          If Not Found Is Nothing Then
             Found.Offset(0, 1).FormulaR1C1 = "=MID(RC[-1],SEARCH(""Time"",RC[-1])+5,8)"
          Else
             MsgBox "No match found."
          End If
    
    End Sub
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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