+ Reply to Thread
Results 1 to 5 of 5

Prevent paste over cell data validation

  1. #1
    Registered User
    Join Date
    10-06-2011
    Location
    Everett, WA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Unhappy Prevent paste over cell data validation

    I searched and found this but neither it nor many other web-searched solutions seems to work. Can't figure what I'm doing wrong. I'm using Excel 2007 in Windows 7.

    http://www.excelforum.com/excel-gene...on-cell-2.html

    I have a number of users with their own spreadsheets, and I'm supposed to consolidate them so summaries and graphs can be made for reporting to higher management. The existing cells are full of mixed numbers, dates and text, so I'm creating a template with columns with data validation.

    Of course, when they start using my template, they will want to copy/paste their original mixtures, and the validation will be lost.

    Thank you for any help.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Prevent paste over cell data validation

    Hi, Dairy_Queen,

    did you put the codes behind the sheet where the event is supposed to work? And with the altered security management from 2007 on you have to make sure that the macros on the template are active to get the codes to work (trusted location as an example).

    And please do not start multiple threads on the same topic (please have a look at the Forums rules for that - thanks in advance, other thread).

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    10-06-2011
    Location
    Everett, WA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Prevent paste over cell data validation

    Thank you for the prompt reply. I started a new thread because the Forum Administrator told me to; I had put it in the old one originally. Newbie, you know.

    Now, I'll look at the trusted location and see if that's what's wrong.

    I do have macros enabled, and the suffix on the file is ...xlsm. And I pasted the vba code in starting inside the sheet with the cell validation, using Alt-F11, and inserting the module into This Workbook. Then I exited with Alt-Q, saved the workbook, closed it, re-opened it, enabled macros, and tried to paste into a validated cell. It always pastes over and the validation is lost.

    Have tried several different vba offerings from a variety of threads and web searches. No joy.

    Thank you for offering to help. Do hope this can be fixed.

    Judy
    (aka Dairy_Queen)

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Prevent paste over cell data validation

    Hi, Judy,

    the code doesn´t go into ThisWorkbook but must be behind the sheet. Right-Click on the worksheet Tab and choose View Code to get there for sure.

    If you are located in the Code window there are 2 comboboxes placed over it. In the left one you can choose from all objects available in that section, in the right one all objects related to the selection are listed. So while you are in ThisWorkbook and choose Workbook you will find all events firing from there. In ThisWorkbook there is only Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) which would fire the event on every worksheet in the workbook. VBA will not recognize the Worksheet_Change-event in ThisWorkbook, only behind the sheet it is recognized and will get fired.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    10-06-2011
    Location
    Everett, WA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Prevent paste over cell data validation

    It worked! Thank you, thank you.

    I thought I had started out doing it that way and it hadn't worked then, but no matter. It works now. I can get on with the rest of the project at last.

    Now to figure out how to give you credit for solving this...

+ Reply to Thread

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