+ Reply to Thread
Results 1 to 8 of 8

Ensuring Validation sticks to a range

Hybrid View

  1. #1
    Registered User
    Join Date
    06-19-2011
    Location
    blackpool, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Post Ensuring Validation sticks to a range

    I'm trying to make it so that validation sticks to a range.

    for example I want everything in column B to only allow input that corresponds to the data in my pick list.

    So Range("B:B")
    My picklist or range of data that's valid being S1:S10

    If someone cuts a cell anywhere in Cell B and places it elsewhere, whatever cell was cut will not be blank, the validation requirements will be reapplied to Range("B:B")

    Thanks for your help in advance

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Ensuring Validation sticks to a range

    Do right click on sheet tab and select view code and paste the below code. Return to excel and check

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    If Target.Column <> 2 Then Exit Sub
    
    With Target.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=$S$1:$S$10"
    End With
    
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Ensuring Validation sticks to a range

    Hi Djarn,

    A suggestion would be to apply the Conditional Formatting (CF) via VBA instead of the usual way using a Formula in the standard CF feature.

    I've had issues with CF 'moving' when Cells values move & this solved the problem for me.

    Hth
    Last edited by noboffinme; 11-07-2013 at 04:03 AM.
    Remember you are unique, like everyone else

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Ensuring Validation sticks to a range

    Quote Originally Posted by noboffinme View Post
    I've had issues with CF 'moving' when Cells values move
    Can you please brief the above quoted sentence for my better understanding

  5. #5
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Ensuring Validation sticks to a range

    Hi Sixthsense,

    I had created a report for a Colleague using Formulas with CF & found an unexplained range change happening with the original CF 'Applies to' ranges.

    On further investigation, I found that the colleague was inserting & deleting Rows which also changed the CF ranges & the report started to format in strange ways due to this.

    I also could not replicate the error until I found out that insert/delete was happening...

    So, my solution was to just format based on cell values using VBA & it solved the problem immediately.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Ensuring Validation sticks to a range

    Make use of $ symbols in Reference Or Indirect Function to keep the STATIC reference.

  7. #7
    Registered User
    Join Date
    06-19-2011
    Location
    blackpool, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Ensuring Validation sticks to a range

    I appreciate the help

    I'll try the code out later, it's really similar to what I tried but I see one or two differences, many thanks again

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Ensuring Validation sticks to a range

    Yes please try it and if you don't get the better results then please attach a file so that it will be helpful to fix the issue

+ 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. EXCEL: Ensuring Data Validation Is Not Deleted
    By gaikwad.mm@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-05-2013, 01:36 AM
  2. data validation - ensuring a blank
    By tariq1 in forum Excel General
    Replies: 3
    Last Post: 11-18-2010, 12:19 PM
  3. [SOLVED] Selection sticks in Excel
    By Thom in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-18-2006, 05:40 PM
  4. [SOLVED] John Walkenbach - Ensuring that Data Validation is Not Deleted
    By al007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-17-2005, 05:10 AM
  5. Mouse sticks in select range mode
    By NaughtyMouse in forum Excel General
    Replies: 8
    Last Post: 11-05-2005, 09:35 PM

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