View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jonathan Brown Jonathan Brown is offline
external usenet poster
 
Posts: 47
Default Select a range based on Fill Color

I need to select a range starting from the cell above the activecell and
continuing upward and stopping when it finds the first cell that contains a
fill color. In other words, I need to select the first group of cells above
the active cell that all have "no fill" as their fill color.

I then want to take that range and plug it into the =COUNTA() formula for
the activecell. But first I just want to find the range, I'll worry about
the formula later.

Here's what I've written so far which doesn't seem to be working:

Private Sub CommandButton1_Click()

Dim StartCell As Range

Set StartCell = ActiveCell

Do While ActiveCell.Interior.ColorIndex = xlColorIndexNone
Range(StartCell & ":" & ActiveCell.Offset(-1, 0)).Select
Loop

End Sub

Anybody have an idea on how to do this?