+ Reply to Thread
Results 1 to 7 of 7

Pasting data as values only ignores data validation

  1. #1
    Registered User
    Join Date
    12-31-2012
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    58

    Pasting data as values only ignores data validation

    I have used the below code to allow people only paste values into a workbook:

    Please Login or Register  to view this content.
    The issue is cells data is pasted to are data validated. The VBA code ignores it and lets paste values that would not normally pass validation. How to fix this?
    Last edited by buhaj47; 08-08-2018 at 04:10 PM. Reason: VBA code found

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Pasting data as values only ignores data validation

    I cannot see any Event Macro that will recognise a paste.

    So

    I would use a worksheet change macro to find all the cells with data validation and check that they are all compliant.

    If not I would use the Undo function.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Pasting data as values only ignores data validation

    Please attach an Excel sample
    - Battle without fear gives no glory - Just try

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Pasting data as values only ignores data validation

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 08-08-2018 at 07:10 PM.

  5. #5
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Pasting data as values only ignores data validation

    Copy/paste destroys the data validation. Its basically treated like a format.

    You can replicate the same thing manually doing a copy paste over data validation (even just copy/paste, not special).

    You need to check the values using the worksheet change event to enforce this if using copy/paste. Its likely you would face similar issues or errors using range.value to assign the value from another cell vs copy/paste.

    You may consider essentially getting or storing the validation rules so you may re-apply them post paste, but I think youll still need to check for and enforce it via VBA to prevent pasting undesired values.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Pasting data as values only ignores data validation

    I came up with a better solution.

    I have started it for you.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-31-2012
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    58

    Re: Pasting data as values only ignores data validation

    I have attached an example - when you provide a value manually, then data validation will tell you if you got it wrong. With the VBA code, I can put something like 5400% and the error is not recognized.
    Attached Files Attached Files
    Last edited by buhaj47; 08-09-2018 at 03:31 AM. Reason: Updated attachment

+ 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. Replies: 6
    Last Post: 08-11-2017, 08:47 PM
  2. [SOLVED] Need help on repeating values in columns based on the table people count
    By elayaz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-13-2016, 08:32 AM
  3. Organize 35 people into groups of 5 over 9 days; minimize same people together
    By LuluPearl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2015, 07:12 AM
  4. Replies: 5
    Last Post: 05-30-2014, 04:53 AM
  5. copy formula and paste for new data added and autofill.....and paste special values
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-13-2014, 07:40 AM
  6. Replies: 13
    Last Post: 08-17-2011, 02:16 PM
  7. Counting people in excel and attaching values
    By dawsonsoo in forum Excel General
    Replies: 3
    Last Post: 12-18-2009, 03:53 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