how do i protect a cell from being change but allow others

beeman

New Member
Joined
Jun 1, 2011
Messages
17
I have been tasked with writing a user friendly analytical template at work. It is for some of our staff that has very poor excel skills. I know more and better training would be the more logical approach, however they are all 5 years and lower to retirement and this would be harder then you can possibly imagin.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
What I have is a template with two buttons. One to add a line and copy the previous row formulas, as follows:
<o:p></o:p>
Private Sub CommandButton4_Click()<o:p></o:p>
'make new row<o:p></o:p>
ActiveCell.EntireRow.Insert shift:=xlDown<o:p></o:p>
'copy the row<o:p></o:p>
ActiveCell.Offset(1).EntireRow.Copy Cells(ActiveCell.Row, 1)<o:p></o:p>
On Error Resume Next<o:p></o:p>
End Sub
<o:p></o:p>
And another to delete a line
<o:p></o:p>
Private Sub CommandButton3_Click()<o:p></o:p>
'to delet row<o:p></o:p>
ActiveCell.EntireRow.Delete<o:p></o:p>
End Sub
<o:p></o:p>
They both work great provided the excel worksheet isn’t protected.
<o:p></o:p>
My problem is on the rows I want to be able to add a line and delete a line I also have some formulas I need protected. When I protect the document these macro’s stop working.
<o:p></o:p>
If I set the macro up to unlock the page do the change and then relock it non of the cells are protected from the delete button. Some of the staff are click happy and would end up deleteing the entire document before they relize it.
<o:p></o:p>
What I need is either a code to prevent these macro’s from working on a specified area but allow it on another. (This area would of course always change as rows are added and deleted), or I need a different way to protect my regular formulas and headings so these macro’s will work.
<o:p></o:p>
Thanks for your help and time.
 
I took a few programming classes in college to round out a mechanical engineering program. Picked up a few books (mostly AutoCAD VBA). For Excel VBA I've never needed anything other than the macro recorder (AutoCAD didn't have a macro recorder) and this website to get almost everything Excel specific that I've needed so far. The books I've used are so old that they would probably be special order if available at all. I would go to the book store and thumb through what they had. If I thought I already knew a lot of the material presented I would look for something else that had a lot of stuff I didn't know.

I've seen others make book/training recommendations on this site. I'd keep an eye out for those types of threads.

Gary
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top