prevent deleting ad text

jethro4640

New Member
Joined
Apr 13, 2016
Messages
4
Good Afternoon,

I was tasked with making a "logbook" document that would act much like pen and paper.
I've gotten a macro to add a new line to the top of the worksheet (keeping the most recent entry on top so the user doesn't have to scroll down hundreds of rows to add a new entry). That same macro then adds a date/time stamp to the new "A1" cell and auto selects A2 cell for the user to type.

Now they want it to be protected from alterations right after the row is finished. I've added the protection selection for rows 2 and beyond in the macro but just realized that when the macro does it, it doesn't put in a password.

Then i tried to have locked cells unselect-able, but unlocked cells selectable and format-able. Then i would have had the macro add a new row (1), select the now-row (2) and then go into format-cells and put a check in the "lock" box. my hope was that it would have then added that worksheet's already password protected rights to that new row. what i found out is that if there is ANY cell protected on that worksheet the "protection tab" in "format cell" is removed for other cells. Any ideas?

below is the code that did what i'm looking for the most - added a row, locked the previous row - but didn't have the required password protection.

Code:
Sub Macro15()'
' Macro15 Macro
'


'
    Rows("1:1").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "=NOW()"
    Range("A1").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
    Range("B1").Select
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Range("A2:H38").Select
    Selection.Locked = True
    Selection.FormulaHidden = False
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingCells:=True, AllowInsertingRows:=True, AllowSorting:= _
        True, AllowFiltering:=True
    Range("b1").Select
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,214,840
Messages
6,121,895
Members
449,058
Latest member
Guy Boot

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