my typo,
BordersAround should be BorderAround (singular)
for weight you can do xlMedium or xlThin as well
Also, specialcells will raise an error if it doesn't find cells to satisfy
the condition, so you can suppress that with
Sub ApplyBorders()
On Error Resume Next
For Each cell In ActiveSheet.Cells.SpecialCells(xlFormulas)
If cell <> "" Then
cell.BorderAround ColorIndex:=1, Weight:=xlMedium
cell.Interior.ColorIndex = 2
End If
Next
For Each cell In ActiveSheet.Cells.SpecialCells(xlConstants)
If cell <> "" Then
cell.BorderAround ColorIndex:=1, Weight:=xlMedium
cell.Interior.ColorIndex = 2
End If
Next
On Error GoTo 0
End Sub
--
Regards,
Tom Ogilvy
Tom Ogilvy said:
Assume by value you mean the cell is not blank or does not appear blank.
for each cell in ActiveSheet.Cells.SpecialCells(xlformulas)
if cell<> "" then
cell.BordersAround ColorIndex:=1, Weight:=xlThick
cell.Interior.ColorIndex = 2
end if
Next
for each cell in ActiveSheet.Cells.SpecialCells(xlConstants)
if cell<> "" then
cell.BordersAround ColorIndex:=1, Weight:=xlThick
cell.Interior.ColorIndex = 2
end if
Next