Consulting

Results 1 to 7 of 7

Thread: Finding all ranges EXCEPT those with color fill

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location

    Finding all ranges EXCEPT those with color fill

    I have a workbook that contains multiple ranges that are filled with color.

    I need to develop the code that will delete ALL OTHER cell contents.

    BUT, the worksheet the code will work on will NOT have the fills.

    So, what I want to do is find a way to "report" to me all those ranges that are not filled so I can make the code use those ranges to delete the cell contents.

    Anybody have any direction for me?
    ~Anne Troy

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    What do you mean 'all ranges'?? There are a lot of cells in one worksheet.

    Also, do you not know the fill color?

  3. #3
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Sure, but I only want to select the cells that DON'T have any fill.
    ~Anne Troy

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Okay, but that's a lot of cells. Do you not want to trim it down first? All the way to row 65,536??

  5. #5
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    LOL. Nevermind. I've got it. I recorded a macro selecting all those ranges.

    However, if you want to finish up this question, my "inside range" is A1:V1055

    So this could be a KB: Select All Cells with Fill Color

    Or you can just delete the whole dern thread.
    ~Anne Troy

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Well, basically you could use this ...

    Option Explicit
    
    Sub SelectNONcoloredCells()
        Dim cel As Range, rng As Range, tmpC As Range
        Set rng = Range("A1:V1055")
        For Each cel In rng
            If cel.Interior.ColorIndex = -4142 Then
                If tmpC Is Nothing Then
                    Set tmpC = cel
                Else
                    Set tmpC = Union(cel, tmpC)
                End If
            End If
        Next cel
        If Not tmpC Is Nothing Then
            tmpC.Select
            'other code here
        End If
    End Sub

  7. #7
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Cool!!
    ~Anne Troy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •