+ Reply to Thread
Results 1 to 2 of 2

find the word and highlighst vba extention

Hybrid View

  1. #1
    Registered User
    Join Date
    03-05-2012
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    42

    find the word and highlighst vba extention

    find the word and highlighst vba extention below code is for one word monkey
    in this only i want to search more words how?
    Sub example()

    Dim iLoop As Integer
    Dim i As Integer
    Dim rNa As Range

    ' count number of monkeys in Activesheet (change to sheet required)
    iLoop = WorksheetFunction.CountIf(ActiveSheet.UsedRange, "*" & "monkey" & "*")

    ' loop through and find monkeys
    Set rNa = ActiveSheet.Range("A1") ' change sheet if necessary
    For i = 1 To iLoop
    Set rNa = Cells.Find(What:="monkey", After:=rNa, _
    LookIn:=xlValues, LookAt:=xlPart, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False)
    ' highlight the rows
    rNa.EntireRow.Interior.ColorIndex = 36
    Next i

    End Sub
    Last edited by gsrikanth; 03-15-2012 at 06:58 AM. Reason: can extend this code

  2. #2
    Registered User
    Join Date
    03-05-2012
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: find the word and highlighst vba extention

    Quote Originally Posted by gsrikanth View Post
    find the word and highlighst vba extention below code is for one word monkey
    in this only i want to search more words how?
    Sub example()

    Dim iLoop As Integer
    Dim i As Integer
    Dim rNa As Range

    ' count number of monkeys in Activesheet (change to sheet required)
    iLoop = WorksheetFunction.CountIf(ActiveSheet.UsedRange, "*" & "monkey" & "*")

    ' loop through and find monkeys
    Set rNa = ActiveSheet.Range("A1") ' change sheet if necessary
    For i = 1 To iLoop
    Set rNa = Cells.Find(What:="monkey", After:=rNa, _
    LookIn:=xlValues, LookAt:=xlPart, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False)
    ' highlight the rows
    rNa.EntireRow.Interior.ColorIndex = 36
    Next i

    End Sub

    can we extend this code

+ 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