Question : Protect Cell Validation

I have a range of cells locked and some input cells unlocked for data entry.  For the unlocked cells I have applied validation to ensure only decimal numbers are input into the cells.

This works great except there is nothing to stop the user copying a text cell from another workbook and pasting into the cell with validation thereby overcoming the validation check.

Is there anyway to apply a secure validation check to Excel 2010?  I'd have thought so by now.

Answer : Protect Cell Validation

On your worksheet, right click the tab and select 'View Code...'

Paste the following code in the Macroeditor that opens.
You will have to change the input ranges to be checked as required. (in my example checked input ranges are D1:D5 and F3:F5)

You can now switch off the sheet validation.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D1:D5", "F1:F5")) Is Nothing Then
    If Not IsNumeric(Target.Value) Then
        MsgBox "Unacceptable input"
        Target.Clear
   End If
End If
End Sub
Random Solutions  
 
programming4us programming4us