PC Review


Reply
Thread Tools Rate Thread

Allow Input, restrict deletion & Share Workbook

 
 
=?Utf-8?B?QktN?=
Guest
Posts: n/a
 
      3rd Sep 2007
I saw a solution for "Allowing Input, but restricting deletion" once data is
entered into a cell and it works great (thanks Gord Dibben), however, it does
not work when I set my workbook up for sharing. I need to have a workbook
that many people can access but once the cell is populated, then it cannot be
changed. The event code worked great until I tried to share the workbook. Is
this possible??
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Sep 2007
I would bet that Gord's suggestion unprotected the worksheet, change the locked
property for the newly changed cell to locked and then reprotected the
worksheet.

But since you've shared the workbook, then the protection of the worksheet
change be changed.

This may work for you.

1. Unshare the workbook.
2. Lock the cells that can't be changed
3. Unlock the cells that are ok for data entry
4. Create a new worksheet named Hidden and hide that worksheet
5. Add this code to the worksheet module that should have this behavior (not
the Hidden worksheet)

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim HiddenWks As Worksheet
Dim myArea As Range

Set HiddenWks = Worksheets("Hidden")

On Error GoTo ErrHandler:

If Application.CountA(HiddenWks.Range(Target.Address)) > 0 Then
With Application
.EnableEvents = False
.Undo
.EnableEvents = True
MsgBox "That range has been already been entered--change undone!"
End With
Else
For Each myArea In Target.Areas
HiddenWks.Range(myArea.Address).Value = myArea.Value
Next myArea
End If

ErrHandler:
Application.EnableEvents = True

End Sub

======
It tries to mirror the changes in that hidden sheet. If the user fills in a
cell that's alread got something in the same location, then it does and
Edit|Undo (in code) and changes things back.

Don't allow the users to insert/delete rows or columns when you protect your
real worksheet. It'll screw everything up.

BKM wrote:
>
> I saw a solution for "Allowing Input, but restricting deletion" once data is
> entered into a cell and it works great (thanks Gord Dibben), however, it does
> not work when I set my workbook up for sharing. I need to have a workbook
> that many people can access but once the cell is populated, then it cannot be
> changed. The event code worked great until I tried to share the workbook. Is
> this possible??


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?QktN?=
Guest
Posts: n/a
 
      3rd Sep 2007
Dave,
*You are great, however, I don't know code and it gave me an error and I
don't know how to fix it.
Compile error: Ambiguous name detectd worksheet_change

*Then it goes to the second line in your code:
Private Sub Worksheet_Change(ByVal Target As Range)

I am guessing I need to change something to be relative to my document, but
am not sure what.

Can you help a hopeless Newbie??

Thanks!!

"Dave Peterson" wrote:

> I would bet that Gord's suggestion unprotected the worksheet, change the locked
> property for the newly changed cell to locked and then reprotected the
> worksheet.
>
> But since you've shared the workbook, then the protection of the worksheet
> change be changed.
>
> This may work for you.
>
> 1. Unshare the workbook.
> 2. Lock the cells that can't be changed
> 3. Unlock the cells that are ok for data entry
> 4. Create a new worksheet named Hidden and hide that worksheet
> 5. Add this code to the worksheet module that should have this behavior (not
> the Hidden worksheet)
>
> Option Explicit
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> Dim HiddenWks As Worksheet
> Dim myArea As Range
>
> Set HiddenWks = Worksheets("Hidden")
>
> On Error GoTo ErrHandler:
>
> If Application.CountA(HiddenWks.Range(Target.Address)) > 0 Then
> With Application
> .EnableEvents = False
> .Undo
> .EnableEvents = True
> MsgBox "That range has been already been entered--change undone!"
> End With
> Else
> For Each myArea In Target.Areas
> HiddenWks.Range(myArea.Address).Value = myArea.Value
> Next myArea
> End If
>
> ErrHandler:
> Application.EnableEvents = True
>
> End Sub
>
> ======
> It tries to mirror the changes in that hidden sheet. If the user fills in a
> cell that's alread got something in the same location, then it does and
> Edit|Undo (in code) and changes things back.
>
> Don't allow the users to insert/delete rows or columns when you protect your
> real worksheet. It'll screw everything up.
>
> BKM wrote:
> >
> > I saw a solution for "Allowing Input, but restricting deletion" once data is
> > entered into a cell and it works great (thanks Gord Dibben), however, it does
> > not work when I set my workbook up for sharing. I need to have a workbook
> > that many people can access but once the cell is populated, then it cannot be
> > changed. The event code worked great until I tried to share the workbook. Is
> > this possible??

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
=?Utf-8?B?QktN?=
Guest
Posts: n/a
 
      3rd Sep 2007
Never mind!!! I just realized that I had to delete the code I had entered
per Gord's suggestion. I deleted that and now it works beautifully.

You are a genius!! Thank you!
Barbara

"Dave Peterson" wrote:

> I would bet that Gord's suggestion unprotected the worksheet, change the locked
> property for the newly changed cell to locked and then reprotected the
> worksheet.
>
> But since you've shared the workbook, then the protection of the worksheet
> change be changed.
>
> This may work for you.
>
> 1. Unshare the workbook.
> 2. Lock the cells that can't be changed
> 3. Unlock the cells that are ok for data entry
> 4. Create a new worksheet named Hidden and hide that worksheet
> 5. Add this code to the worksheet module that should have this behavior (not
> the Hidden worksheet)
>
> Option Explicit
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> Dim HiddenWks As Worksheet
> Dim myArea As Range
>
> Set HiddenWks = Worksheets("Hidden")
>
> On Error GoTo ErrHandler:
>
> If Application.CountA(HiddenWks.Range(Target.Address)) > 0 Then
> With Application
> .EnableEvents = False
> .Undo
> .EnableEvents = True
> MsgBox "That range has been already been entered--change undone!"
> End With
> Else
> For Each myArea In Target.Areas
> HiddenWks.Range(myArea.Address).Value = myArea.Value
> Next myArea
> End If
>
> ErrHandler:
> Application.EnableEvents = True
>
> End Sub
>
> ======
> It tries to mirror the changes in that hidden sheet. If the user fills in a
> cell that's alread got something in the same location, then it does and
> Edit|Undo (in code) and changes things back.
>
> Don't allow the users to insert/delete rows or columns when you protect your
> real worksheet. It'll screw everything up.
>
> BKM wrote:
> >
> > I saw a solution for "Allowing Input, but restricting deletion" once data is
> > entered into a cell and it works great (thanks Gord Dibben), however, it does
> > not work when I set my workbook up for sharing. I need to have a workbook
> > that many people can access but once the cell is populated, then it cannot be
> > changed. The event code worked great until I tried to share the workbook. Is
> > this possible??

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Sep 2007
You could delete that first
..enableevents = true

It'll be picked up in the errhandler.



Dave Peterson wrote:
>
> I would bet that Gord's suggestion unprotected the worksheet, change the locked
> property for the newly changed cell to locked and then reprotected the
> worksheet.
>
> But since you've shared the workbook, then the protection of the worksheet
> change be changed.
>
> This may work for you.
>
> 1. Unshare the workbook.
> 2. Lock the cells that can't be changed
> 3. Unlock the cells that are ok for data entry
> 4. Create a new worksheet named Hidden and hide that worksheet
> 5. Add this code to the worksheet module that should have this behavior (not
> the Hidden worksheet)
>
> Option Explicit
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> Dim HiddenWks As Worksheet
> Dim myArea As Range
>
> Set HiddenWks = Worksheets("Hidden")
>
> On Error GoTo ErrHandler:
>
> If Application.CountA(HiddenWks.Range(Target.Address)) > 0 Then
> With Application
> .EnableEvents = False
> .Undo
> .EnableEvents = True
> MsgBox "That range has been already been entered--change undone!"
> End With
> Else
> For Each myArea In Target.Areas
> HiddenWks.Range(myArea.Address).Value = myArea.Value
> Next myArea
> End If
>
> ErrHandler:
> Application.EnableEvents = True
>
> End Sub
>
> ======
> It tries to mirror the changes in that hidden sheet. If the user fills in a
> cell that's alread got something in the same location, then it does and
> Edit|Undo (in code) and changes things back.
>
> Don't allow the users to insert/delete rows or columns when you protect your
> real worksheet. It'll screw everything up.
>
> BKM wrote:
> >
> > I saw a solution for "Allowing Input, but restricting deletion" once data is
> > entered into a cell and it works great (thanks Gord Dibben), however, it does
> > not work when I set my workbook up for sharing. I need to have a workbook
> > that many people can access but once the cell is populated, then it cannot be
> > changed. The event code worked great until I tried to share the workbook. Is
> > this possible??

>
> --
>
> Dave Peterson


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
NTFS - Restrict file deletion Volker Putt Windows XP General 13 9th Jul 2009 04:41 PM
Restrict Directory Deletion miztaken Microsoft C# .NET 1 22nd Sep 2008 10:52 AM
How to restrict task editing and deletion in Outlook 2003 ? pavel.gz@gmail.com Microsoft Outlook Program Addins 2 11th Oct 2006 02:30 PM
Restrict Deletion of Document =?Utf-8?B?TGlmZSBDb250YWluZWQ=?= Microsoft Word Document Management 1 31st Jul 2006 01:11 AM
Restrict cell deletion starguy Microsoft Excel Misc 5 23rd Jun 2006 11:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 AM.