+ Reply to Thread
Results 1 to 15 of 15

Data validation macro bug

  1. #1
    Registered User
    Join Date
    04-07-2014
    Location
    Berkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Data validation macro bug

    Hello all

    I have data validation of various kinds implimented within a worksheet. When you copy and paste a cell over a cell with data validation in, it overwrites the validation.

    I've found the following macro which is meant to check that the named range of cells, "ValidationRange" still have data validation following any cell or range being edited in the worksheet. In this case I have named cells O9:R10,U9:AR10 as the range "ValidationRange" as these are the cells I have with preexisiting data validation. Found at this site: http://www.j-walk.com/ss/excel/tips/tip98.htm

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This macro doesn't seem to work. Excel either responds with "Rune-time error '29': Out of stack space" with the debug option greyed out.

    Or the message box pops up "Your last operation was canceled. It would have deleted data validation rules." And then either
    1. I click OK and the box doesn't go away (basically reappears as soon as I click OK) or
    2. I click OK and then get "Run-time error '1004': Method 'Undo' of object'_Application' failed" with the debug option greyed out

    Whatever happens usually results in Excel crashing also..

    Thanks all

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Data validation macro bug

    You should always disable events if you are going to make changes in a Change event:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    04-07-2014
    Location
    Berkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Data validation macro bug

    Hi Rory

    Thanks for the response. That code still allows me to copy and paste over validation which is what I'm trying to prevent!

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Data validation macro bug

    I think the original code is actually flawed, although it shouldn't let you copy over the validation. Try something like this:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-07-2014
    Location
    Berkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Data validation macro bug

    Still allows copy and pasting to overwrite..

    Thanks

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Data validation macro bug

    Not for me. Can you post your revised version for testing please?

  7. #7
    Registered User
    Join Date
    04-07-2014
    Location
    Berkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Data validation macro bug

    Thanks
    Attached Files Attached Files

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Data validation macro bug

    I see the message if I try and paste anything over the top of those cells and it gets undone. Try restarting Excel in case your events have become disabled.

  9. #9
    Registered User
    Join Date
    04-07-2014
    Location
    Berkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Data validation macro bug

    Ah - I restarted Windows and it works - thanks. Is there a fix that''ll make it always work? It will be a shared spreadsheet when its finished and I need to make sure its always functioning for all users.

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Data validation macro bug

    I think it was caused by the problems you had originally - it should work in general use.

  11. #11
    Registered User
    Join Date
    04-07-2014
    Location
    Berkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Data validation macro bug

    Sharing the workbook prevents it from working - any ideas?

    Thanks

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Data validation macro bug

    You shouldn't be able to change Data Validation settings in a Shared Workbook anyway, so there shouldn't be any need for the code.

  13. #13
    Registered User
    Join Date
    04-07-2014
    Location
    Berkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Data validation macro bug

    Yes I know, but copying and pasting a cell with no validation over a cell with validation overwrites it, whether the workbook is shared or not

  14. #14
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Data validation macro bug

    Not for me - I just tested it in your workbook. I'd advise against using shared workbooks anyway.

  15. #15
    Registered User
    Join Date
    04-07-2014
    Location
    Berkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Data validation macro bug

    Hmm, I suppose it's one of those things then. I'll contact our useless IT department.

    Thanks for all your help

+ 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. Data Validation Macro
    By mattman123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2013, 01:36 PM
  2. Macro that detects and circles invalid data automatically (Data Validation)
    By dchubbock in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2012, 09:07 AM
  3. I need a macro to enter data based on data validation lists.
    By DorothyFan1 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-30-2012, 08:58 AM
  4. Stop Worksheet_Change macro if validation not met in Data Validation
    By Wizz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2010, 12:26 PM
  5. Data Validation Macro
    By Kohinoor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2009, 03:21 AM

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