View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
S30 via OfficeKB.com S30 via OfficeKB.com is offline
external usenet poster
 
Posts: 4
Default Finding unlocked cells in Excel

Hi All,

I have a macro which find and adds color to all unlocked/unprotected cells in
Excel. Unfortunately once I remove the color from unlocked cells the macro
also removes original colors applied to the cells prior to running these
macros.

Any ideas of how I could improve these macros?

Thanks a lot in advance

Steve

Sub Color_Unprotected_cells()
Application.ScreenUpdating = False
Set A = ActiveWorkbook.ActiveSheet
For Each Sheet In ActiveWorkbook.Worksheets
Sheet.Activate
Sheet.Cells.Select
For Each Item In Intersect(ActiveSheet.UsedRange, Selection.Cells)

'Item.Value = Item.Interior.ColorIndex
If Item.Locked = False Then
Item.Interior.ColorIndex = 37
End If
Next
ActiveSheet.Range("A1").Select
Next Sheet
A.Activate
Application.ScreenUpdating = True
End Sub

Sub Remove_Color_Unprotected_cells()
Application.ScreenUpdating = False
Set A = ActiveWorkbook.ActiveSheet
For Each Sheet In ActiveWorkbook.Worksheets
Sheet.Activate
ActiveSheet.Cells.Select
For Each Item In Intersect(ActiveSheet.UsedRange, Selection.Cells)
If Item.Locked = False Then
Item.Interior.ColorIndex = xlNone
End If
Next
ActiveSheet.Range("A1").Select
Next Sheet
A.Activate
Application.ScreenUpdating = True
End Sub

--
Message posted via http://www.officekb.com