Hi GTO
Thanks for your quick reply.
I did as you proposed and tried out the code from the link that you provided. Unfortunately, it seems that the code somehow interferes with the rest of my project so I get a Method 'List' of object '_CommandBarComboBox' failed error message.
So I got back to my original code and changed it to the following:
Private Sub Worksheet_Change(ByVal Target As Range) 'or Target as Excel.Range
'code forces 'simple pasting' to be performed as 'paste values' if data is pasted into cell B8
'Target is a variable which represents the last changed cell
On Error GoTo errorHandler
Application.EnableEvents = False
If Not Intersect(Target, Range("B8")) Is Nothing And Target.Count = 1 Then 'If Target.Address = Range("B8") Then <~~ did not work
If Application.CutCopyMode = xlCopy Then
Application.Undo
Target.Select
ActiveSheet.PasteSpecial Format:="Text", Link:=False, displayasicon:=False ', NoHTMLFormatting:=True <~~ had no effect
Target.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=False
End If
End If
errorHandler:
MsgBox "Error #" & Err.Number & " - " & Err.Description
Application.EnableEvents = True
End Sub
This results in an 1004 error at run-time (PasteSpecial method of Worksheet class failed).
I cannot tell which line is causing the error but both PasteSpecial methods show the following expressions which are not being capitalized by the editor:
displayasicon:=False
operation:=xlNone
skipblanks:=False
This is all very frustrating given the fact that I started with the following code (which works like a charm):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'code forces 'simple pasting' to be performed as 'paste values'
On Error Resume Next
If Application.CutCopyMode = xlCopy Then
Application.EnableEvents = False
Application.Undo
Target.Select
ActiveSheet.PasteSpecial Format:="Text"
Target.PasteSpecial Paste:=xlPasteValues
Application.EnableEvents = True
End If
End Sub
Having spent much more time on this than what I deem would be appropriate I am going to stick eventually to the simple yet working code above.
Unless of course, somebody will come up with a bright idea...
Thanks to everyone for reading.
Hope I haven't wasted your time.
Cheers
Dennis