Problem after unprotecting a sheet

judgejustin

Board Regular
Joined
Mar 3, 2014
Messages
150
I am using the following code to insert some data and formatting. It works fine until I try to add protection to one of the sheets. The problem is the section of code that seems to be an issue shouldn't be effected, or at least I don't understand how it could be effected. The part that stops working is when the code pastes the formatting.
I need to unprotect another sheet in this code as well but I was only doing one at the time. Any help would be great. If I can get this one figured out I may need help with protection on the other sheet in the code as well. At this point I just don't know.
Code:
Sub Insert_Record()
'
' Insert_Record Macro
'

'
    ActiveWindow.SmallScroll Down:=22
    Range("D34:D49").Select
    Selection.Copy
    ActiveWindow.SmallScroll Down:=13
    Range("H54").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
    Range("H54:AC54").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Inventory Sheet").Select
    Range("A5:V5").Select
    With Sheets("Inventory Sheet")
    .Unprotect "TEST"
    Selection.Insert Shift:=xlDown
 
   Selection.PasteSpecial Paste:=xlPasteAllMergingConditionalFormats, Operation _
        :=xlNone, SkipBlanks:=False, Transpose:=False

    .Protect "TEST"
    End With
    Sheets("New Record Entry").Select
    ActiveWindow.SmallScroll ToRight:=-4
    ActiveWindow.SmallScroll Down:=-31
    Range("C27:F27").Select
    ActiveCell.FormulaR1C1 = ""
    Range("F24").Select
    ActiveCell.FormulaR1C1 = ""
    Range("C24").Select
    ActiveCell.FormulaR1C1 = ""
    Range("F20").Select
    ActiveCell.FormulaR1C1 = ""
    Range("C20").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D16").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D14").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D12").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D10").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D8").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D4").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D6:E6").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D4").Select
End Sub
 
Last edited:

Forum statistics

Threads
1,226,796
Messages
6,193,048
Members
453,772
Latest member
aastupin

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