I have a code which runs when a cell changes in column B.

Code:

```
'Insert Depot Memo Data for user
 Dim oCell As Range, targetCell As Range
    Dim ws2 As Worksheet

    If Not Intersect(Target, Range("B:B")) Is Nothing Then ' <-- run this code only if a value in column B has changed
        If ActiveCell.Value <> "" Then
        If Not GetWb("Depot Memo", ws2) Then Exit Sub

        With ws2
            For Each targetCell In Target
                Set oCell = .Range("J1", .Cells(.Rows.Count, "J").End(xlUp)).Find(What:=targetCell.Value, LookIn:=xlValues, LookAt:=xlWhole)
                If ActiveCell.Value <> "" Then
                If Not oCell Is Nothing Then
                    Application.EnableEvents = False

                    'Set Format of cell
                    targetCell.ClearFormats
                    targetCell.Font.Name = "Arial"
                    targetCell.Font.Size = "10"
                    targetCell.Font.Color = RGB(128, 128, 128)
                    targetCell.HorizontalAlignment = xlCenter
                    targetCell.VerticalAlignment = xlCenter
                   targetCell.Borders(xlEdgeBottom).LineStyle = xlContinuous
                    targetCell.Borders(xlEdgeTop).LineStyle = xlContinuous
                   targetCell.Borders.Color = RGB(166, 166, 166)
                   targetCell.Borders.Weight = xlThin

                    targetCell.Offset(0, -1).Value = Now()
                    targetCell.Offset(0, 1).Value = oCell.Offset(0, 1)
                     targetCell.Offset(0, 2).Value = oCell.Offset(0, -2)
                     targetCell.Offset(0, 3).Value = oCell.Offset(0, -7)

                     With Range("A9:P1048576")
                     .FormatConditions.Delete
                     .FormatConditions.Add Type:=xlExpression, Formula1:="=ROW(B9)=ROW(OFFSET($B$9,COUNTA($B:$B)-2,0))"

                     With .FormatConditions(1).Borders
                     .LineStyle = xlContinuous
                     .Color = vbRed
                     .Weight = xlThin
                     End With

                     End With

                    Application.EnableEvents = True
                End If
                End If
            Next
        End With
    End If
    End If

```

Mostly the code works fine.
Except i want to add conditional formatting to a range when the cell has changed.

This also works, and adds a red border around the next available (empty row).
However, i do not want a red border around the whole row. I just want top and bottom borders. 

So i am trying to do this:

```
 With .FormatConditions(1).Borders(xlEdgeTop)
                         .LineStyle = xlContinuous
                         .Color = vbRed
                         .Weight = xlThin
                         End With

```

But then my code stops working and i get this error

[![enter image description here](https://i.stack.imgur.com/nyKgO.png)](https://i.stack.imgur.com/nyKgO.png)

Please can someone show me where i am going wrong?