Thread: For Each
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_5_] Bob Phillips[_5_] is offline
external usenet poster
 
Posts: 620
Default For Each

Martin,

I don't understand, this seems to work for me. What values do you have in
K9:K31.

--

HTH

Bob Phillips

"Martin Wheeler" wrote in message
...
xl2000
I am trying to get the code below to perform an operation on each cell in
the range("K9:K31").
Currently it only looks at the cells K9, K10 and any blank cells in the
range. It then changes the color of the border regardless of whether or

not
the cell's value is valid.
Any help would be greatly appreciated.
Ta,
Martin
Public Sub Gap()
Dim HC As Range
Dim HD As Range
Set HC = Range("K11")
Set HD = Range("K12")
For Each HC In Range("K9:K31")
If HC.Value <= (0.7 * HD.Value) Then
With HC.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 26
End With
End If
Next
End Sub