Ensuring Conditional formating is not lost
David (and for anyone else who might be interested in this solution)
I've just cracked it in the following way:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myCell As Range
On Error GoTo ErrHandler:
For Each myCell In Target.Cells
If HasCF(myCell) Then
'do nothing
Else
With Application
.EnableEvents = False
.Undo
MsgBox "Standard paste not allowed please use paste special and select
paste values only. " & _
"See help for further details", vbCritical
Exit For
End With
End If
Next myCell
ErrHandler:
Application.EnableEvents = True
End Sub
Private Function HasCF(r As Range) As Boolean
Dim x As Long
x = r.FormatConditions.Count
HasCF = CBool(x < 0)
End Function
|