Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 54
Default Macro Button or Auto Protect Formula

Is there anyway I can protect only cells that have data. eg after
entering data for a number of lines I would like to protect only the cells
that have data in one step.

Therefore when the worksheet is opened again the user can continue to enter
data and in one step protect what has been done.
Thanks
AR
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 108
Default Macro Button or Auto Protect Formula

I don't protect data much so I'm not sure what other solutions there may be.
But I think you could do this by writing a VBA program; it would use the
Worksheet_Change event, and set protection for the new cell if its value is
non-blank. That would save the protection between sessions, too. Dunno
whether you like that idea, though, since you posted this in the Worksheet
Functions group.

--- "enna49" wrote:
Is there anyway I can protect only cells that have data. eg after
entering data for a number of lines I would like to protect only the cells
that have data in one step.

Therefore when the worksheet is opened again the user can continue to enter
data and in one step protect what has been done.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Macro Button or Auto Protect Formula

Assuming you have all cells unlocked on a clean sheet.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="justme" 'adjust to suit
With Target
If .Value < "" Then
.Locked = True
End If
End With
enditall:
Application.EnableEvents = True
With Me
.Protect Password:="justme"
End With
End Sub

As you enter data in a cell, it will locked and protected from editing.

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste the code into that sheet module.

Adjust password if you want then Alt + q to return to the Excel window.


Gord Dibben MS Excel MVP


On Tue, 12 Aug 2008 18:52:00 -0700, enna49
wrote:

Is there anyway I can protect only cells that have data. eg after
entering data for a number of lines I would like to protect only the cells
that have data in one step.

Therefore when the worksheet is opened again the user can continue to enter
data and in one step protect what has been done.
Thanks
AR


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 54
Default Macro Button or Auto Protect Formula

Hi

Thanks for your response

This works as it protects the sheet.
As soon as I unprotect the sheet I can only enter data into one blank cell
and then all blank cells are protected. I can change the cells that have
data already input to them. What I require is the cells with data to be
protected and the blank cells to remain unprotected.
Appreciate you help
Thanks



"Gord Dibben" wrote:

Assuming you have all cells unlocked on a clean sheet.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="justme" 'adjust to suit
With Target
If .Value < "" Then
.Locked = True
End If
End With
enditall:
Application.EnableEvents = True
With Me
.Protect Password:="justme"
End With
End Sub

As you enter data in a cell, it will locked and protected from editing.

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste the code into that sheet module.

Adjust password if you want then Alt + q to return to the Excel window.


Gord Dibben MS Excel MVP


On Tue, 12 Aug 2008 18:52:00 -0700, enna49
wrote:

Is there anyway I can protect only cells that have data. eg after
entering data for a number of lines I would like to protect only the cells
that have data in one step.

Therefore when the worksheet is opened again the user can continue to enter
data and in one step protect what has been done.
Thanks
AR



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
Macro to allow auto filter after running password protect Roady Excel Discussion (Misc queries) 1 July 17th 08 06:34 PM
password protect the button in Excel? cfman Excel Discussion (Misc queries) 3 March 2nd 07 09:06 PM
Macro or Custom button to fill in the same formula TJ Excel Worksheet Functions 4 March 15th 06 10:33 PM
How to protect option button? Julie Excel Worksheet Functions 1 March 23rd 05 03:42 AM
How to protect Option button in worksheet Julie Excel Worksheet Functions 2 January 4th 05 01:01 AM


All times are GMT +1. The time now is 04:29 AM.

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"