View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
davethewelder davethewelder is offline
external usenet poster
 
Posts: 62
Default Format cell and adjacent cell

Hi, I am trying to put a conditional format to format a cell plus the
adjacent cell immediately to the right with a heavy black border round the
two cells. I have tried the code below but I get an error message
"Appplication defined or Object defined error". The code ran previously but
it did not reference the cell or apply the border format. I' ve ran out of
ideas so any help would be apprecieated.

Davie


Sub Borders()
'

Cells.Select
Range("A12").Activate
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=$B$66"
With Selection.FormatConditions(1).Borders

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With

End Sub