Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default lock cell after value is automatically placed when workbook is ope

I am trying to lock a cell after todays date is placed into the cell. I want
this date to remain in the cell so when the application is re opened the
original date remains.

Does anyone have any ideas?

The script below that I am using falls over at the Selection.Locked = True
line of code.


Private Sub Workbook_Open()
If ActiveWorkbook.Name = "Status Report Template.xls" Then
NewNameforTemplate
End If
Application.DisplayAlerts = True
ThisWorkbook.Sheets("Form").Range("$E$12").Select
Selection.Value = Format(Now(), "dd mmm yyyy")
ThisWorkbook.Sheets("Form").Range("$E$12").Select
Selection.Locked = True
On Error Resume Next
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default lock cell after value is automatically placed when workbook is ope


Damien wrote:
I am trying to lock a cell after todays date is placed into the cell. I want
this date to remain in the cell so when the application is re opened the
original date remains.

Does anyone have any ideas?

The script below that I am using falls over at the Selection.Locked = True
line of code.


Private Sub Workbook_Open()
If ActiveWorkbook.Name = "Status Report Template.xls" Then
NewNameforTemplate
End If
Application.DisplayAlerts = True
ThisWorkbook.Sheets("Form").Range("$E$12").Select
Selection.Value = Format(Now(), "dd mmm yyyy")
ThisWorkbook.Sheets("Form").Range("$E$12").Select
Selection.Locked = True
On Error Resume Next
End Sub


you could replace this Selection.Value = Format(Now(), "dd mmm yyyy")
with these lines
If Selection.Locked = True Then Exit Sub ' do this to advoid an error
message if selection is locked & sheet protected.

If Selection.Value = "" Then Selection.Value = Format(Now(), "dd mmm
yyyy")

NOTE: remember locked only works if the sheet is protected.

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
Lock sheets automatically Thu Ng[_2_] Excel Discussion (Misc queries) 2 November 18th 09 02:16 AM
can a cell be automatically populated with the workbook name? crawdood Excel Worksheet Functions 4 August 14th 07 04:42 PM
Lock cell in a shared workbook Raj New Users to Excel 1 December 17th 06 11:53 AM
automatically move cell data in 1 workbook to another workbook Genesis Excel Worksheet Functions 1 November 5th 06 07:35 PM
How do I lock a cell automatically after it has data entered. Dandy Excel Discussion (Misc queries) 0 March 30th 06 12:39 PM


All times are GMT +1. The time now is 10:32 PM.

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

About Us

"It's about Microsoft Excel"