validating

  • Thread starter Thread starter Philashley
  • Start date Start date
P

Philashley

How do I prevent people from pasting any data into cells that have a drop
down list?
 
This is from the reply by Elkar to a similar previous question:

Add this code to your workbook (use Alt-F11 to open the VB Editor, then
double-click "ThisWorkbook", then copy/paste the below code)

Private Sub Workbook_Activate()
Application.CutCopyMode = None
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Application.CutCopyMode = None
End Sub

NOTE: If the user disables macros when the workbook is opened, then this
won't work.

Hope this helps,

Hutch
 
The code in my previous reply prevents all paste operations in the workbook.
We can modify the code to prevent pasting only to specific cells. If you just
wanted to keep the user from pasting to B10 on Sheet1, you could use:

Private Sub Workbook_Activate()
Application.CutCopyMode = None
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Sh.Name <> "Sheet1" Then Exit Sub
If Intersect(Target, Range("B10")) Is Nothing Then Exit Sub
Application.CutCopyMode = None
End Sub

This could be expanded for multiple cells.

Hutch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top