+ Reply to Thread
Results 1 to 4 of 4

Add inputmessage without removing existing data validation

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    16

    Add inputmessage without removing existing data validation

    Excel 2007
    I have a worksheet that has several ranges with data validation (for example allowing only integers or list items). I also run the macro below to add the last modified date in the "input message". The problem is that the ".delete" part of the code removes the preexisting data validation.

    I cannot find a way to circumvent this problem: I tried simply disabling the ".delete" part of the code, didn't work. I tried writing code that that would store the old data validation and combine it with the inputmessage, but I failed. Is this possible, and if yes - could you point me in the right direction?

    Thanks!

    Please Login or Register  to view this content.
    P.S. should I include the ".delete" code I mention in the first two paragraphs in #code tags on this forum? It seems to me that doing that for a single word would make things a bit messy.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Add inputmessage without removing existing data validation

    Hi MrsAlice and welcome to the forum,

    I'd suggest you not do data validation on those cells and do the entire checking using VBA.
    Use code in the Change Event and check whatever is input. VBA can do what Validation does with messages and more.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Add inputmessage without removing existing data validation

    Try something like this:
    Please Login or Register  to view this content.
    The odd formulation of the intersection is because of a quirk of special cells.
    If rng is a single cell, rgn.SpecialCells returns the same as applying .SpecialCells to the whole sheet.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    05-15-2012
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    16

    Re: Add inputmessage without removing existing data validation

    Thank you MarvinP for your recommendation and Mikerickson for your code. I will look into data validation through VBA at a later stage.

    Mikerickson's code works perfectly on cells that contain data validation. A cell that does not contain data validation does however not receive the "timestamp". After reading my opening post again I realized I did not describe the problem specific enough. I apologize for that!

    Is there a way to modify the existing code to apply to the specialcells & regular cells all the same?

    (In this imperfect world I just gave data validation to all cells that did not so far, text length less than 99999)
    Last edited by MrsAlice; 07-26-2012 at 09:39 PM. Reason: Added the last line

+ 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