![]() |
Have code check cell contents on edit.
Hi,
I am trying to identify if there is a way of having a worksheet unprotected but preventing a cell from being edited (using the 'F2' button or simply typing into it) if there is a formulae in it ('=' in the first character). I can see how to check after the change has been made using Worksheet_Change(ByVal Target As Range) but is there 'BEFORE_CHANGE' method. The reason I want this is becuase we want end users to be able to sort, insert etc as usual but if they select cell 'B4' and type or press the 'F2' button a message box will appear saying they can't edit. Andrew 160108 -- Andrew |
Have code check cell contents on edit.
Hi Andrew,
Can use the Change event and the Selection_Change events together. With the Selection_Change event you record the contents of a cell that the user moves to and store this in a global variable. If the user makes change to the restricted area the Change event 1. puts the value of the variable back into the cell and then displays a warning message. By the way you can protect the worksheet and still allow inserting of rows and columns, sorting and many other things. -- Cheers, Shane Devenshire "Andrew" wrote: Hi, I am trying to identify if there is a way of having a worksheet unprotected but preventing a cell from being edited (using the 'F2' button or simply typing into it) if there is a formulae in it ('=' in the first character). I can see how to check after the change has been made using Worksheet_Change(ByVal Target As Range) but is there 'BEFORE_CHANGE' method. The reason I want this is becuase we want end users to be able to sort, insert etc as usual but if they select cell 'B4' and type or press the 'F2' button a message box will appear saying they can't edit. Andrew 160108 -- Andrew |
All times are GMT +1. The time now is 11:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com