First. A worksheet event macro must be in the SHEET module (or ThisWorkbook for all shts). Try this simpler approach using all vba . '======= option explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim mf As Range If Target.Column <> 1 Then Exit Sub 'If Target.Address <> Range("c1").Address Then Exit Sub' NOT used Set mf = Range("a1:a4").Find(What:=Target, LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) If mf Is Nothing Then Application.EnableEvents = False Target = "" Application.EnableEvents = True MsgBox "Invalid Entry" End If End Sub '===========
On Friday, October 5, 2012 7:17:02 AM UTC-5, Sourabh wrote: > > Hi, > > I am using Excel 2003 and have drop down cells with validations. I want to > restrict the copy-paste functionality for these drop-down cells. i have > written a macro for that purpose but it disables the copy-paste for entire > worksheet. > > Appreciate if you could help me with a macro that checks for the values in > the drop-down list and if the value matches with that the user is going to > paste then it allows to paste else it gives an error message " Not a valid > entry " > > For example in the attachment(See attached file) there are 4 entries in > the drop-down list. If the user tries to paste any random value say "abcd" > or "1234" then an error message should be shown and the user must not be > able to paste BUT if user pastes a value(Unclassified or any of the 4 > items) that matches the drop-down list values the paste should be allowed. > > Can you please help me with this, I have written a macro but its not > working can you please check or advice what am i missing or doing wrong. > > I am attaching the macro enable Excel sheet for your reference so that you > can have look at the macro that i have written. > > Thanks > Sourabh > -- Join official facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES (1120+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. 6) Jobs posting is not allowed. 7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To post to this group, send email to excel-macros@googlegroups.com. To unsubscribe from this group, send email to excel-macros+unsubscr...@googlegroups.com.