offset command protected

G

Guest

Hi

I am currently using a macro that allows me to insert a row preserving
formulas by a doubleclick.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True 'Eliminate Edit status due to doubleclick
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy Target.Offset(1).EntireRow
On Error Resume Next
Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

Reference: David McRitchie

My problem is when i protect my worksheet, this macro fails to operate when
it gets to the "Target.EntireRow.Copy Target.Offset(1).EntireRow" part.

When protecting i enabled all exceptions and still doesnt work. Is there a
way around this. Sorry, I am quite new at all this. Thanks
 
D

Dave Peterson

Maybe you can just add a couple of lines:

Private Sub Worksheet_BeforeDoubleClick(...

me.unprotect password:="whatever"

'your existing code

me.protect password:="whatever"

end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top