Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I wrote a macro that would change the colour and value of selected cell(s). I want users to be able to use this macro only if the selected cell(s) are not locked. (locked cells in the spreadsheet are the ones containing formulas, and i don't want the users to change that). Here is the code i wrote: Sub Approved() ' check that selection is not a protected cell With Selection If .Locked = True Then MsgBox "Sorry! You selected a locked cell." Exit Sub End If End With ActiveSheet.Unprotect Selection.Interior.ColorIndex = 35 'Light Green Selection.value = "Approved" End Sub The above code works well when the selection consists of one cell only, or when the selection consists of a range of cells that all have the same formatting (either ALL locked, or ALL unlocked). However, when i tested the code by selecting a range that includes both locked and unlocked cells, the code didn't seem to know the difference and was run according to the formatting of the FIRST cell in the selected range. What do i need to change in order to detect if there is at least one locked cell in the selected range? i'm using Excel 2003. Many thanks Tendresse |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
manually selected Excel cell formatting | Excel Discussion (Misc queries) | |||
Conditional formatting won't update until cell is selected: Excel | Excel Discussion (Misc queries) | |||
Does the selected cell have a range name? | Excel Programming | |||
Referencing the First Cell in Any Selected Range | Excel Programming | |||
Macro run if and cell in range is selected in VBA | Excel Programming |