View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
slb0927 slb0927 is offline
external usenet poster
 
Posts: 3
Default how do I create a macro to select all colored cells in a works

That works except when there are consecutive cells with color. I prefer the
outer border for this exercise but will use this code in the future for other
worksheets. Thanks so much for taking the time to respond.

"Master Blaster" wrote:

On Jan 31, 8:06 pm, slb0927 wrote:
Need help writing the code for an Excel Macro that would find all cells that
have any interior color so that an outer border can be added around all
colored cells.


If you adjust the range than the code below is simple and works.

Sub Select_Colored_Cells()

For r = 1 To 30
For k = 1 To 30

If Cells(r, k).Interior.ColorIndex < xlNone Then
Cells(r, k).Select
Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
End If

Next k
Next r
End Sub
.