Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Validation problem (Excel 2003)

    Hi,

    Is there a way to prevent this scenario?

    I apply validation into a range to prevent a number greater than 100 entered into this range. The validation works, but a person can copy a value greater than 100, and paste it into the cells with validation. The paste takes and I and up with a value that is "not allowed" in that range.

    How can I prevent this?
    TX
    Regards,
    Rudi

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Validation problem (Excel 2003)

    Validation only applies to data entered directly by the user. There's no check if you use VBA to fill a cell, and neither when you copy and paste.

    In fact, when you copy and paste, you're copying the validation of the source cells too, so you'll overwrite any validation specified for the target cells! So in all probability the value IS allowed. This is a severe limitation of validation.

    Paste Special with the Values option preserves the validation set for the target cells, but no check is performed.

    So you'll have to educate your users not to copy and paste if validation is involved.

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Validation problem (Excel 2003)

    Many tx for that reply. It confirms a lot.
    Cheers Hans
    Regards,
    Rudi

  4. #4
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Validation problem (Excel 2003)

    Hi Rudi

    Is disabling the copy and paste an option? Here is some code i found a long time ago, possibly on this forum

    Private Sub Workbook_Open()
    On Error Resume Next
    Application.CommandBars("Edit").Controls("&copy"). Enabled = False
    Application.CommandBars("cell").Controls("&copy"). Enabled = False
    Application.OnKey "^c", "disablec"
    End Sub


    Sub disablec()
    MsgBox "Copy command disabled"
    End Sub


    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    On Error Resume Next
    Application.CommandBars("Edit").Controls("&copy"). Enabled = True
    Application.CommandBars("cell").Controls("&copy"). Enabled = True
    Application.OnKey "^c", ""
    End Sub


    'then put this in a module

    Sub disablec()
    MsgBox "Copy command disabled"
    End Sub

    Cheers

    Steve
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  5. #5
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Validation problem (Excel 2003)

    Hi Steve,

    Tx for the code. The request came from a client I was dealing with. I have not been able to contact the client again, but if this issue come up again, your suggestion is worth a mention.

    TX
    Regards,
    Rudi

Posting Permissions

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