Thanks for the reply spitfireblue - I had seen and tried that code from another site but never could get it to work; I think while the code might have worked fine by itself, it didn't want to play nice with the other code I needed in the workbook.
I've managed to get this working successfully using the code in this workbook (also pasted below); There is code in each sheet, plus code in the workbook, as well as a macro saved with a shortcut key of Ctrl + v to override the Ctrl+v function with 'paste values only'.
This workbook does the following:
1) Ensure the end user enables macros, because they cannot see any of the sheets except the warning sheet telling them to enable macros if they don't
2) Replaces both the context menu and Ctrl+v paste commands with "paste special values only" to ensure that the Data Validation on certain cells is not overwritten.
3) once the data is pasted, it looks at every cell with validation and compares the data entered with data validation choices; any that don't match initiate a pop-up asking the user to correct the data.
enable_macros-paste_values_only-post_paste_validation.xlsm
Credits to mikeerickson from post: http://www.excelforum.com/excel-prog...ion-cells.html
Sub postPasteValidation()
Dim validationCells As Range
Dim oneCell As Range
Dim userInput As Variant, promptStr As String
On Error Resume Next
Set validationCells = ActiveSheet.Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not (validationCells Is Nothing) Then
For Each oneCell In validationCells
If Not (oneCell.Validation.Value) Then
promptStr = oneCell.Address & " has a bad value in it." & vbCrLf _
& "Please enter the correct data per" & vbCrLf _
& oneCell.Validation.InputMessage
userInput = Application.InputBox(prompt:=promptStr, Default:=oneCell.Value)
If userInput <> False And oneCell.Value <> vbNullString Then oneCell.Value = userInput
End If
Next oneCell
End If
End Sub
AND
Ken C Johnson (from another site) for sharing their code that I was able to reuse here.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = True
Dim ReminderSht As Worksheet, ReminderTxtBx As Shape, Sht As Object
Set ReminderSht = Me.Worksheets.Add
ReminderSht.Name = "Enable_Macros"
Set ReminderTxtBx = Worksheets("Enable_Macros").Shapes.AddTextbox(msoTextOrientationHorizontal, _
0, 0, Range("A1:D7").Width, Range("A1:D7").Height)
ReminderTxtBx.TextFrame.Characters.Text = _
"When opening this workbook," _
& Chr(10) _
& "you must enable macros ." _
& Chr(10) _
& "Click the ""Enable Content"" button" _
& Chr(10) _
& "or close and then re-open it." _
& Chr(10) _
& "Make sure you click the ""Enable content"" button on the Security dialog."
Range("A1:D7").Select
ActiveWindow.Zoom = True
Range("A1").Select
For Each Sht In Me.Sheets
If Sht.Name <> "Enable_Macros" Then
Sht.Visible = xlVeryHidden
End If
Next Sht
Worksheets("Enable_Macros").Protect "pw"
Me.Protect "pw"
ActiveWorkbook.Save
End Sub
Private Sub Workbook_Open()
Dim Sht As Object
Me.Unprotect "pw"
For Each Sht In Me.Sheets
If Sht.Name <> "Enable_Macros" Then
Sht.Unprotect "pw"
Sht.Visible = xlSheetVisible
End If
Next Sht
For Each Sht In Me.Sheets
If Sht.Name = "Enable_Macros" Then
Application.DisplayAlerts = False
Sht.Delete
Application.DisplayAlerts = True
End If
Next Sht
End Sub
Bookmarks