MACRO.Help pls

bkyeong

New Member
Joined
Apr 9, 2002
Messages
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
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top