![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 24
|
i got a cell (A3) and there is a string inside. i dun want anybody to change it. If somebody try to change it, i want to prompt a message!how to do in excel macro.pls help
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,387
|
Since you are asking for a macro solution, here's one way. You should know that the VBA approach for cell protection is usually less effective than the standard cell-lock-and-sheet-protection method, because the code, unless very extensive (so why bother) allows changes to be made in formatting and spell check. You are better off with standard protection, but here's the code nonetheless. Right click on your sheet tab, left click on View Code, and paste this in:
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("A3")) Is Nothing Then Application.EnableEvents = False MsgBox "Sorry, this cell is protected.", 16, "Access denied." Application.Undo Application.EnableEvents = True End If End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|