View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel Nigel is offline
external usenet poster
 
Posts: 923
Default Creating Borders with a formula

Put the following code behind the worksheet you wish to apply a top border
to a row when the vlaue in column H is set to a 1.
The code is triggered by a change of cell selection and works by scanning
column H from row1 until the last row where column H has a value. If the
value in column H (current row) equals 1 then the entire row topborder is
turned on, else turned off.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lstrow As Long
Dim i As Long
lstrow = Cells(Rows.Count, "H").End(xlUp).Row
For i = 1 To lstrow
With Rows(i).Borders(xlEdgeTop)
If Range("H" & i).Value = 1 Then
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
Else
.LineStyle = xlNone
End If
End With
Next i
End Sub

Cheers
Nigel

"Jeff Fink" wrote in message
...
I am trying to create a top border for a row evverytime
one of the column H is = 1. If anyone knows please post
it or e-mail me at .

Thanks,
Jeff Fink