+ Reply to Thread
Results 1 to 17 of 17

Prevent Paste over Data Validation

  1. #1
    Registered User
    Join Date
    02-07-2006
    Posts
    16

    Prevent Paste over Data Validation

    When users paste data into cell , I need to protect data validation/ conditional formatting etc. How can one do this?
    Last edited by VBA Noob; 04-03-2009 at 01:23 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    This link may help

    http://www.j-walk.com/ss/excel/tips/tip98.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    02-07-2006
    Posts
    16

    Lightbulb

    Hi there , Many Thanks. I actually tried this code, but it did not work. What do you mean by wrap code with # ? ?

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    When you create new posts and need to add code click on the # symbol which is in the toolbar above where you type the text

    Here's an example

    Not wrapped

    Sub Macro9()
    ActiveWindow.ScrollColumn = 1
    End Sub


    Wrapped

    Please Login or Register  to view this content.
    VBA Noob

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Where do you post the code

    Are the users deleting entire rows or columns ??

    That's the only way it won't work

    VBA Noob

  6. #6
    Registered User
    Join Date
    02-07-2006
    Posts
    16
    Hi There , I copied and pasted this code off the Web link into the VBA window of the same sheet in which I am trying to protect the data validation cells.

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    and you followed this instruction from the website

    Important:
    Ensure that every cell in the ValidationRange actually contains Data Validation
    VBA Noob

  8. #8
    Registered User
    Join Date
    02-07-2006
    Posts
    16
    Yes I Did. I am truly lost.

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Mine works fine (See attached)

    Did you rename the range to ValidationRange


    VBA Noob
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    02-07-2006
    Posts
    16
    Hi There , I see your sheet works if you copy and paste into one of the cells , but it does not work if I paste special VALUES as it allows other info not on list to be placed in cell. Also in my case I don't have a list to select, but a custom - formula valadation. I am off home now and will continue tomorrow. Thanks for all your help .

  11. #11
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Here are what is covers

    Limitations
    This procedure handles the following operations, which would normally delete the Data Validation rules:

    Cutting/pasting data
    Copying/pasting data
    The Edit - Clear - All command
    The Edit - Delete command

    If it's not here then it doesn't prevent it

    VBA Noob

  12. #12
    Registered User
    Join Date
    02-07-2006
    Posts
    16

    Many Thanks

    I felt if it work for Copy/Paste it would work for Paste Special as well. Originally I thought that the Data Validation would still be valid even with Copy Paste. This is what I gathered from this link : http://www.alltipsandtricks.com/blog...on-in-ms-excel
    where they say : Tip: the validation property is maintained when applying the Copy – Paste command. Once again , Thanks for your time.

  13. #13
    Registered User
    Join Date
    04-03-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Prevent Paste over Data Validation

    Quote Originally Posted by VBA Noob View Post
    Hi,

    This link may help

    http://www.j-walk.com/ss/excel/tips/tip98.htm

    VBA Noob
    Hey, I know this is an old thread but I am trying to solve this exact problem.

    That link worked for me but there's a problem with it, it does not work if a table has different validations. Does anyone know how I could overcome this problem?

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Prevent Paste over Data Validation

    Please take the time to read the forum rules, and then start your own thread.
    Entia non sunt multiplicanda sine necessitate

  15. #15
    Registered User
    Join Date
    04-03-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Prevent Paste over Data Validation

    Ah sorry shg. Created another thread now.

  16. #16
    Registered User
    Join Date
    09-21-2009
    Location
    preston,england
    MS-Off Ver
    Excel 2007
    Posts
    1

    Smile Re: Prevent Paste over Data Validation

    Quote Originally Posted by VBA Noob View Post
    Mine works fine (See attached)

    Did you rename the range to ValidationRange


    VBA Noob
    Thank you - you're a life saver.....

  17. #17
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Prevent Paste over Data Validation

    Tried this, but when I make a change, the macro gets stuck in a loop because at the 'Application.Undo' step, it returns to the beginning of the sub. The only difference is my named range is 'ValidationRangeThu' (which I have also used in the code).

    I have tested the workbook by VBA Noob, and mine is the same code in the sheet module (apart from the above).

    Any ideas?

    Edit - Any change to the sheet triggers the loop, and I have also tried it with the named range as 'ValidationRange'.
    Edit - It seems it doesn't like non-contiguous ranges, although the description says they are fine. It works correctly with contiguous ranges, but I don't want to have to make multiple ranges with multiple codes.
    Last edited by tone640; 07-01-2011 at 10:55 AM. Reason: Updates

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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