Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 40
Default Lock after entering

Cell B2 has the formula SUM(A1,A3). After entering data in A1 and A3 the sum
appears in B2. I would like to lock only B2 after data entry so it never
changes. Is it possible?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Lock after entering

Start with all cells ujnlocked and the sheet unprotected.

The following worksheet event macro will monitor A1 and A3. Once they are
both filled in, the formula in B2 will be converted to a value and B2 will be
locked:

Private Sub Worksheet_Calculate()
Set a1 = Range("A1")
Set a3 = Range("A3")
Set b2 = Range("B2")
If IsEmpty(a1.Value) Then Exit Sub
If IsEmpty(a3.Value) Then Exit Sub
If Not b2.HasFormula Then Exit Sub
b2.Value = b2.Value
b2.Locked = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200797


"bgkgmg" wrote:

Cell B2 has the formula SUM(A1,A3). After entering data in A1 and A3 the sum
appears in B2. I would like to lock only B2 after data entry so it never
changes. Is it possible?

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I undo the scroll lock, thscroll lock button does not work scroll lock Excel Discussion (Misc queries) 3 July 19th 08 10:17 PM
To lock a cell/cells after entering the value The learner Excel Discussion (Misc queries) 1 January 27th 08 10:46 AM
I have lock a wookbook but one cell does not want to lock it Mimi Excel Discussion (Misc queries) 2 January 21st 07 10:59 PM
I have lock a wookbook but one cell does not want to lock it Mimi Excel Discussion (Misc queries) 1 January 21st 07 09:44 AM
102. not entering the same as 102.00 Stacy Excel Discussion (Misc queries) 8 December 2nd 05 06:02 PM


All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"