locked cells are still SELECTABLE

GregM

New Member
Joined
Jan 15, 2005
Messages
14
Hello XLS friends! :rolleyes:
Pls bear with me as I haven't done macros since L123/DOS. My macro works fine except when the sheet that is named and saved is reopened for future editing the locked cells can be selected. They are still locked and cannot be edited. I verify that the sheet is still protected. I unprotect it and upon re-protecting it find the SELECT LOCKED CELLS is enabled or set to TRUE.
Any help to get me beyond this hump will be greatly appreciated.
Best regards, GregM

Code:
Sub saving()
    
    Dim tempName As String
    tempName = ActiveWorkbook.Name
    
    If tempName <> "InvTemplate.xls" Then
        Exit Sub
    End If

    ' Sheets("Simple Invoice").Protect userinterfaceonly:=True
    ActiveSheet.Unprotect
    [M12].Value = [M12].Value + 1
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveSheet.EnableSelection = xlUnlockedCells
    ActiveSheet.Protect
    
    Application.DisplayAlerts = False
    ThisWorkbook.SaveAs ("C:\Documents and Settings\Marisa\Desktop\Invoices\InvTemplate.xls")
    Application.DisplayAlerts = True
    
    Dim invName As String
    Range("C9").Select
    invName = InputBox("What is the Invoice Name?")
    Range("C9").Value = invName
    invName = invName + "_" + CStr([M12].Value)
    ThisWorkbook.SaveAs ("C:\Documents and Settings\Marisa\Desktop\Invoices\" & invName & ".xls")
     
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi,

Just by unprotecting the sheet, the user will be able to select previously locked cells so you can remove the line:

Code:
ActiveSheet.EnableSelection = xlUnlockedCells
Once you protect the worksheet again the cells will be locked.

Ron
 
Upvote 0
Thanks for the imput Ron. Altho what you say seems logically true, that didn't change anything. Any other ideas?

I'm glad to attach the SS if that'll help. Like I said though, once I reopen the sheet which has been renamed, it is still PROTECTED, but the SELECT LOCKED CELLS is now checked on the Protect Sheet.

I guess the answer is to determine what I'm doing here that causes it to become checked, because I'm CERTAIN that it isn't checked in the initial, protected template.
 
Upvote 0
Hi,

Maybe you can change that initial line to read ActiveSheet.DisableSelection = xlUnlocked Cells and enter it after you Protect the Sheet.

Worth a try.

Ron
 
Upvote 0

Forum statistics

Threads
1,203,600
Messages
6,056,206
Members
444,850
Latest member
dancasta7

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