Format unlocked cells with VBA in a protected sheet but not locked cells

microsoft-excel-2010

I have a worksheet with VBA to colour cells on double click in a portion of the sheet. These cells are unlocked but the cells around them are locked. I want to be able to prevent format of surrounding cells being changed but do want the VBA to change colour of unlocked cells. I would be grateful for your help.

Best Answer

You want only macro changes to take effect? Protect the user interface:

Sheet1.Protect Password:="Password", UserInterfaceOnly:=True

Related Question