Gabriel222
New Member
- Joined
- Oct 24, 2008
- Messages
- 14
- Office Version
- 365
- Platform
- Windows
Hello,
I'm a little new to VBA, and i ran into a piece of VBA code which would prevent my data validation from being erased (either through a copy/paste or other).
I implemented the code (i believe in the right place, although i'm not sure), and upon testing the code's VBA generated message box came up about a hundred times, and basically forced me to restart excel
.
Does anybody have any suggestions as to make this piece of code work?
Private Sub Worksheet_Change(ByVal Target As Range)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
></o
>
Dim VT As Long<o
></o
>
'Do all cells in the validation range<o
></o
>
'still have validation?<o
></o
>
On Error Resume Next<o
></o
>
VT = Range("InputRange").Validation.Type<o
></o
>
If Err.Number <> 0 Then<o
></o
>
Application.Undo<o
></o
>
MsgBox "Your last operation was canceled." & _<o
></o
>
"It would have deleted data validation rules.", vbCritical<o
></o
>
End If<o
></o
>
End Sub<o
></o
>
Thank you
I'm a little new to VBA, and i ran into a piece of VBA code which would prevent my data validation from being erased (either through a copy/paste or other).
I implemented the code (i believe in the right place, although i'm not sure), and upon testing the code's VBA generated message box came up about a hundred times, and basically forced me to restart excel

Does anybody have any suggestions as to make this piece of code work?
Private Sub Worksheet_Change(ByVal Target As Range)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com




Dim VT As Long<o


'Do all cells in the validation range<o


'still have validation?<o


On Error Resume Next<o


VT = Range("InputRange").Validation.Type<o


If Err.Number <> 0 Then<o


Application.Undo<o


MsgBox "Your last operation was canceled." & _<o


"It would have deleted data validation rules.", vbCritical<o


End If<o


End Sub<o


Thank you
Last edited: