Thread: For Each
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Martin Wheeler Martin Wheeler is offline
external usenet poster
 
Posts: 57
Default For Each

Hi JS
Thanks for your reply.
I am getting a type mismatch error and it is highlighting
If HC.Value <= (0.7 * HC.Offset(1, 0).Value) Then
The same applies to acw's solution below
Ta,
Martin

"JS" wrote in message
...
hi Martin - i see what you mean, try the following code

Sub Gap()

Dim cell As Range

For Each cell In Range("K9:K31")
If cell.Offset(1, 0) < "" Then
If cell.Value (0.7 * (cell.Offset(1, 0).Value)) Then
With cell.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 26
End With
End If
End If
Next cell

End Sub