View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Format cell if contains a value

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" wrote in message
...
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

--
Regards,
Tom Ogilvy


"sjbeeny " wrote in message
...
Hi, all

How would I (at the click of an activeX button) format cells with
borders and make the cells fill colour white if it has a value in it?

Cheers,
Simon

B.T.W
Thanks for all your help for a newbie


---
Message posted from http://www.ExcelForum.com/