LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default For Each

Thanks Tom,
As usual your code works great.
Ta,
Martin

"Tom Ogilvy" wrote in message
...
If you are using excel 97

Public Sub Gap()
Dim HC As Range
Dim HD As Range
For Each HC In Range("K9:K31")
If HC.Offset(1, 0) < "" and HC <"" Then
if isnumeric(HC.offset(1,0).value) _
and isnumeric(HC.value) then
If HC.Value <= (0.7 * HC.Offset(1, 0).Value) Then
With HC.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 26
End With
End If
End if
End If
Next
End Sub

Regards,
Tom Ogilvy




Martin Wheeler wrote in message
...
Hi JS
I have been doing a bit of playing with yours and acw's code and now

have
Public Sub Gap()
Dim HC As Range
Dim HD As Range
For Each HC In Range("K9:K31")
If HC.Offset(1, 0) < "" Then
If HC.Value <= (0.7 * HC.Offset(1, 0).Value) Then
With HC.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 26
End With
End If
End If
Next
End Sub
This works but am still getting the type mismatch error
Ta,
Martin
"Martin Wheeler" wrote in message
...
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











 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"