Thank you, Norman, works great!
I tried converting the sub to a function that returns the range of
cells with a given interior color index value as follows:
Function findColorInRange(searchrange As range, colorix As Integer)
Dim resultrange As range
Dim rCell As range
For Each rCell In searchrange.Cells
If rCell.Interior.ColorIndex = colorix Then
If resultrange Is Nothing Then
Set resultrange = rCell
Else
Set resultrange = Union(rCell, resultrange)
End If
End If
Next rCell
findColorInRange = resultrange
End Function
However, I get an error (run-time error 91) when I try to call with:
Sub testing()
Dim rng As range
rng = findColorInRange(range("database"), 38)
End Sub
Any ideas? I have the feeling I'm missing something basic, but I don't
know much about calling routines in macros.