Results 1 to 1 of 1

Prevent copy paste over data validation in multiple columns

Threaded View

  1. #1
    Registered User
    Join Date
    09-12-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    2

    Prevent copy paste over data validation in multiple columns

    HI All,
    I tried the below code to prevent Copy pasting data to Data validation. It works if I try in a single column. My challenge is that I have data validation in 6 to 7 columns which vaies from Col. C to X. I cant able to prevent those using the below code from copy paste. Requiring your experts help



    Private Sub Worksheet_Change(ByVal Target As Range)
        'Does the validation range still have validation?
        If HasValidation(Range("ValidationRange")) Then
            Exit Sub
        Else
            Application.Undo
            MsgBox "Your last operation was canceled." & _
            "It would have deleted data validation rules.", vbCritical
        End If
    End Sub
    
    Private Function HasValidation(r) As Boolean
    '   Returns True if every cell in Range r uses Data Validation
        On Error Resume Next
        x = r.Validation.Type
        If Err.Number = 0 Then HasValidation = True Else HasValidation = False
    End Function


    Regards,
    Vivek T

    Moderator's Edit: Use code tags when posting code. To do so in future, select your code and click on the # icon at the top of your post window.
    Last edited by arlu1201; 01-10-2013 at 02:18 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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