Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Allowing input, but restricting deletion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
innovate - 07 Jun 2007 18:56 GMT
Hi all,

Is it possible to allow input into a spreadsheet, but at the same time
making sure that data that is inputted is impossible to delete?

Hope you guys can help,
Roland
Dave Peterson - 07 Jun 2007 19:45 GMT
You may be able to do something with some sort of worksheet event.  But I'd be
worried about typos.  How would you go about fixing those if the cell was locked
after I finished my initial input?

> Hi all,
>
[quoted text clipped - 3 lines]
> Hope you guys can help,
> Roland

Signature

Dave Peterson

Gord Dibben - 07 Jun 2007 20:31 GMT
Not without some event code that would prevent the deletion after input.

Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.

Alt + q to return to Excel window.

CTRL + a to select all cells.

Format>Cells>Protection........uncheck "locked"

As written, the event code will operate on any cell in columns A:D to lock the
cell after data input.  Options for other ranges can be provided to suit.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column < 5 Then
ActiveSheet.Unprotect Password:="justme"
      If Target.Value <> "" Then
      Target.Locked = True
       End If
   End If
enditall:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme"
End Sub

To prevent users from seeing the code and password, protect the project from
viewing.

Alt + F11 to open Visual Basic Editor.

Select your workbook/project and right-click>VBAProject
Properties>Protection>Lock for Viewing.  Apply a password and save/close the
workbook.

When re-opened, code will be unviewable or uneditable.

Gord Dibben  MS Excel MVP

>Hi all,
>
[quoted text clipped - 3 lines]
>Hope you guys can help,
>Roland
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.