+ Reply to Thread
Results 1 to 15 of 15

How to prevent pasting the wrong values in a cell which already have a data validation?

  1. #1
    Registered User
    Join Date
    05-30-2014
    Posts
    23

    How to prevent pasting the wrong values in a cell which already have a data validation?

    Hi Team,

    I have one sheet which has one column named as Resource Designation and it has drop-down with three values to select Manager,Clerical and Professional. I had put this using Data Validation , selecting the type as list and also put an error message if wrong value is entered b user.

    My problem is , if user is pasting the values from an other excel sheet , it is taking wrong values like "Management" , data validation is not working when the user is copy pasting the values.

    Please let me know the solution , i will be grateful to you all .

    I will attach the sample sheet with the same data validation but not the original sheet .



    Thanks
    Timmu
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi
    I have managed to find some code (written by another Forum Member) that appears to do what you want. The range A2:A13 has been renamed to "ValidationRange". Whenever someone tried to cut and paste data into any cell within this range a message will pop up advising the user they cannot past data into these cells.
    Hope this helps.
    Tony
    Attached Files Attached Files
    Last edited by ARGK; 05-30-2014 at 04:23 AM.

  3. #3
    Registered User
    Join Date
    05-30-2014
    Posts
    23

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi Tony,
    Thanks!!

    This is working fine when we are copying into the data validation cell from the same sheet like as you have written Clerk beside that data validation cell.

    But when we are copying the same Clerk from different excel workbook , it is not showing up any error.

    Is there any solution for this?

    Please let me know

    Thanks
    Timmu

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi Timmu
    I have posted a question on the forum that the code originally came from and if I get an answere I will come back to you.
    Thanks
    Tony

  5. #5
    Registered User
    Join Date
    05-30-2014
    Posts
    23

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi Tony,

    I got one reply from you to my mail saying

    Hi
    The only way to prevent data in cells being pasted is to override the built in Ctrl+V paste option with a macro that tells the user they cannot use paste on this worksheet as it would remove the data validation rules. See my sample attached. The Macro has been given a shortcut name of Ctrl+V which overfrides the muilt in paste function of Excel. Try copying some data into Col A.
    Hope this helps
    Tony


    can you please provide me that sample?

  6. #6
    Registered User
    Join Date
    05-30-2014
    Posts
    23

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi ,

    Any progress for my question above , please let me know.

    Thanks
    Timmu

  7. #7
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi Timmu
    Sorry, here is a very simple Macro which over-rides the Ctrl V option in MS Word:
    Sub PreventPaste()
    '
    ' Macro1 Macro
    '
    ' Keyboard Shortcut: Ctrl+v
    '
    MsgBox ("You cannot paste data into this workbook...")
    Range("A1").Select
    End Sub
    Paste this into a module in your Workbook.
    This will only stop them using Ctrl V to paste data. They will still be able to use the paste option on the Home toolbar (unless you remove it from the toolbar). If you do this it will affect all documents created under that template.
    Hope this helps.
    Tony

  8. #8
    Registered User
    Join Date
    05-30-2014
    Posts
    23

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi Tony,

    Thanks for the reply. I have one more issue , is it possible to validate the wrongly pasted values in the drop-down containing data Validation?

    For example in my case , i have a drop-down for A1 with Data Validation having List of 3 values Manager,Professional , Clerical. If i paste say Management from a different sheet into the sheet containing A1 , it should pop-up the message saying "you have entered the incorrect value , please check" .

    Is it possible to handle?

    Please help

    Thanks
    Mounika

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Pl see the attached file. It may be helpful.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-30-2014
    Posts
    23

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi kvsrinivasamurthy,

    You are really great , awesome , no words for you salute to you heart-fully!!


    Thanks

  11. #11
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Thanks for the compliments.Pl mark the thread SOLVED. Use Thread Tools.

  12. #12
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi Mounika
    Replace all code behind the Worksheet with this code and it should do the trick:
    Please Login or Register  to view this content.
    Hope this helps.
    Good luck.
    Tony

  13. #13
    Registered User
    Join Date
    05-30-2014
    Posts
    23

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Hi Srinivasamurthy,

    In the solution you provided , how to give the dynamic range? Actually we have 55 resources (rows) but we can add extra resources through one button(assigned one macro to it) . In the code you provided I added Range till 55 but when we add extra resources then the code will not work as i gave till 55 only , next will be 56 and for 56 this code will not work. How to handle this situation , hope you understood my problem

    If Not Intersect(Target, Range("E10:E55")) Is Nothing Then
    k = ActiveCell.Validation.Type
    m = WorksheetFunction.CountIf(Val_rng, Target.Value)


    Thanks again
    Mounika

  14. #14
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Try changing the range "E10:E55" as "E10:E65"

  15. #15
    Registered User
    Join Date
    05-30-2014
    Posts
    23

    Re: How to prevent pasting the wrong values in a cell which already have a data validation

    Thanks very much , it solved my problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Prevent pasting over data validation
    By antho27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2014, 02:54 PM
  2. Unable to prevent copy pasting data that does not conform to data validation rules
    By Sree Varun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-25-2013, 10:41 PM
  3. Prevent copying and pasting a cell from a column with data validation to another column
    By kieranoduill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2013, 10:02 AM
  4. prevent pasting wrong values over validated cells
    By giligili in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2013, 07:31 AM
  5. Prevent pasting over validation
    By BuzzT in forum Excel General
    Replies: 1
    Last Post: 02-07-2011, 04:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1