Hello,
I am using the 2 below macro one to CUT and PASTE and the other one to COPY and PASTE.
The COPY PASTE macro works fine with my protected workbook but that macro allows me to select various rows or cells and gives me the following error:
--> So my question is would it be possible to only allow one row copy instead of various as workaround as the error doesn't occurred when selecting only one row?? Believe me I have tried to sort that issue out and check hat problem on many forums but I've never been able to find solution
Sub COPYPASTE()
ActiveSheet.Unprotect Password:="p@ssw0rd!"
Dim rngSource As Range, rngDestination As Range
On Error Resume Next
Application.DisplayAlerts = False
Set rngSource = Application.InputBox("Select the entire row to copy. ", "Select Cells", Type:=8)
If rngSource Is Nothing Then GoTo Cleanup 'User canceled
Set rngDestination = Application.InputBox("Select the destination cell to paste to. ", "Select Paste Destination", Type:=8)
If rngDestination Is Nothing Then GoTo Cleanup 'User canceled
On Error GoTo 0
ActiveSheet.Unprotect Password:="p@ssw0rd!"
rngSource.Copy
' rngDestination(1).PasteSpecial xlPasteValues
rngDestination(1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.Goto rngDestination
Cleanup:
Application.DisplayAlerts = True
ActiveSheet.Protect Password:="p@ssw0rd!", AllowFormattingCells:=True
End Sub
Sub CUTPASTE()
Dim rngSource As Range, rngDestination As Range
Set rngSource = ActiveCell.EntireRow
On Error Resume Next
Set rngDestination = Application.InputBox("The active cell's entire row will be cut. " & vbLf & _
"Select the destination cell to insert the cut row.", _
"Move Row", Type:=8)
On Error GoTo 0
If rngDestination Is Nothing Then Exit Sub 'User canceled
ActiveSheet.Unprotect Password:="p@ssw0rd!"
rngSource.Cut
rngDestination.EntireRow.Insert Shift:=xlDown
ActiveSheet.Protect Password:="p@ssw0rd!", AllowFormattingCells:=True
End Sub
Many Thanks,
Graig
Bookmarks