AaronReese
New Member
- Joined
- Jan 29, 2019
- Messages
- 1
Guys,
This one has me stumped
I have a spreadsheet where the users would like to copy a cell and then highlight a range of cells (in the same column) and paste down the value. Unfortunately, some of the rows are locked and the locked rows cannot (and should not) be overwritten
I have the following procedure called from a custom context menu line
Once it has been run, the CutCopyMode appears to be stuck at zero and the macro will then throw a runtime error. After the runtime error it seems to be OK again. If you comment out the error handler, once it has run sucessfully it will continue to jump to the errhandler until you force a runtime error.
The protection around mycell.copy was an attempt to stop it from selecting the last cell and leaving the application in a Copy state (marching ants)
This one has me stumped
I have a spreadsheet where the users would like to copy a cell and then highlight a range of cells (in the same column) and paste down the value. Unfortunately, some of the rows are locked and the locked rows cannot (and should not) be overwritten
I have the following procedure called from a custom context menu line
Code:
Sub customPaste()
'MsgBox "custom Paste"
'MsgBox "message2"
Dim myCell As Range
Dim previousCell As Range
Dim workingRange As Range
Set workingRange = Selection
Call UnprotectSheets
'If Application.CutCopyMode = 0 Then
' MsgBox "WTF!"
' GoTo errhandler
'End If
For Each myCell In workingRange
If (Not (myCell.Locked)) Then
myCell.PasteSpecial Paste:=xlPasteFormulas
DoEvents
If myCell.Address <> workingRange(workingRange.Count).Address Then
myCell.Copy
End If
End If
Next myCell
'errhandler:
Call ProtectSheets
End Sub
The protection around mycell.copy was an attempt to stop it from selecting the last cell and leaving the application in a Copy state (marching ants)
Last edited by a moderator: