+ Reply to Thread
Results 1 to 3 of 3

Thread: Find cells with specific ColorIndex

  1. #1
    Valued Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2003
    Posts
    428

    Find cells with specific ColorIndex

    Hi there,

    How can I change the code to search for cells with specific .Interior.ColorIndex

    Sub FindIt()
        Dim strFindMe As String, rngData As Range
        Dim rngFound As Range, firstaddress As String
         
        strFindMe = Interior.ColorIndex = 42    'the entry To  find
         
        With Worksheets("Sheet1")
        
     
            Set rngData = .Range("B1:AF500")
            'the range To search
            Set rngFound = rngData.Find(strFindMe, LookIn:=xlValues)
            If Not rngFound Is Nothing Then
                firstaddress = rngFound.Address
                Do
                    With rngFound
                         .Interior.ColorIndex = xlNone
                         .ClearContents
                    End With
                    'clear data In the matching cell
                    Set rngFound = rngData.FindNext(rngFound)
                    If rngFound Is Nothing Then Exit Do
                 Loop While rngFound.Address <> firstaddress
            End If
        End With
    End Sub
    Last edited by Bob@Sun; 02-13-2010 at 12:02 PM.

  2. #2
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,523

    Re: Find cells with specific ColorIndex

    Possibly,

    Option Explicit
    
    Sub Reset_Cells()
    
        Dim c As Range
        
        Application.ScreenUpdating = False
        
        With Sheet1
            On Error Resume Next
            For Each c In .Range("B1:AF500")
                If c.Interior.ColorIndex = 42 Then
                    c.Interior.ColorIndex = xlNone
                    c.ClearContents
                End If
            Next
        End With
    
        Application.ScreenUpdating = True
        
    End Sub
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Valued Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2003
    Posts
    428

    Re: Find cells with specific ColorIndex

    Thanks a lot! It works just perfect!

+ 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.2.0