Results 1 to 2 of 2

Thread: [RESOLVED] Searching for a bottom border of a particular color

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    223

    Resolved [RESOLVED] Searching for a bottom border of a particular color

    How would one search a column for the first occurrence of a cell that had a bottom border of a particular ColorIndex?

    I've been Googling and Googling, and I can't find the answer to this question.

    Many thanks!

  2. #2
    Addicted Member kewakl's Avatar
    Join Date
    Oct 2006
    Location
    between keyboard and chair
    Posts
    220

    Re: Searching for a bottom border of a particular color

    Quick sample...
    Simple looping through rows in the column
    test for ColorIndex of Borders(xlEdgeBottom)

    Code:
    Dim lLoopIndex As Long
    Application.StatusBar = "Searching for Bottom BorderColor"
    DoEvents
    Application.ScreenUpdating = False  'Stop Excel showing the selecting of each cell
    For lLoopIndex = 1 To 32767  '<-- You did not say how far down the column that you wanted to search!
        Cells(lLoopIndex, ActiveCell.Column).Select
        If Selection.Borders(xlEdgeBottom).ColorIndex = 4 Then
            Stop
        End If
    Next
    Application.ScreenUpdating = True
    Debug.Print "Searched to " & lLoopIndex
    Application.StatusBar = "Search Complete"
    DoEvents
    you might want to set a var to the current cell and then select that cell when done searching.
    Do not use if shrinkwrap is broken or missing!
    I'm learning how to fish, too!

Posting Permissions

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



Click Here to Expand Forum to Full Width