Thread: For Each
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JS[_4_] JS[_4_] is offline
external usenet poster
 
Posts: 14
Default For Each


hi Martin - not exactly sure whether code below is what you want but by
defining cell as range and looping through each cell in Range("K9:K31") you
will loop through the whole range. If this isn't what you need send me some
more details on the criteria for the loop.

Public Sub Gap()
Dim cell As Range
Dim HC As Range
Dim HD As Range
Set HC = Range("K11")
Set HD = Range("K12")
For Each cell In Range("K9:K31")
If cell.Value < "" And cell.Value <= (0.7 * HD.Value) Then
With cell.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 26
End With
End If
Next cell
End Sub