+ Reply to Thread
Results 1 to 5 of 5

Data Validation on SelectionChange - Works but slow!

  1. #1
    Registered User
    Join Date
    12-09-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    Lightbulb Data Validation on SelectionChange - Works but slow!

    Hi guys,

    Firstly, this forum is exceptional - 9/10 out of 10 I manage to find an answer. This time round though I am a little stuck.

    On one of the spreadsheets I have a type of role mapping exerise - if it's a 1:1 then only a '1' can be entered, if it's a 1:M an 'x' can be entered. Only these values can be entered (Due to more VBA that runs a report for every name and then it lists the roles etc they are mapped to and different counts going on).

    Due to the roles listed a long the top being dynamic and changing when imported (roles being added and removed) I need the cells data validation to change with that range.

    Please Login or Register  to view this content.
    It is a little clunky and I have tried many different ways, else statements etc but nothing speeds it up.

    The problem I have is that every time I click a cell the spinning timmer pops up for a split second, but enough to be a problem. Is anybody please able to help tighten up this code to be far sexier and faster?

    Thanks in advance...

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,758

    Re: Data Validation on SelectionChange - Works but slow!

    I might be missing something, but you only need the DV refreshed for the row you have just selected. So why are you using EntireRow?

    I'd try taking that out first.

    If it doesn't help, we probably could do with a sample workbook with some typical data.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Data Validation on SelectionChange - Works but slow!

    If I understand what you are doing correctly, then maybe you avoid vba altogether? put something like:
    =IF(A1="M",A2,A3)
    as data validation list in A4, then put "1" in A2 and "x" in A3.

    You should be extend this method to work for your columns.

  4. #4
    Registered User
    Join Date
    12-09-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Data Validation on SelectionChange - Works but slow!

    Thanks for the quick reply.

    So row 6 contains the detail whether it is 1:1 or 1:M. Each column needs to be validated for as many rows down as long as there are users (thus entirecolumn), based on the value in the column, in row6. Does that make sense?

    Thanks,
    J

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,758

    Re: Data Validation on SelectionChange - Works but slow!

    Every time you select a cell anywhere on the sheet, you are going to loop through columns P to NA checking if they are M or 1 and, if they are you're going to delete and refresh the Data Validation for the Entire Column ... that's over a million cells, by dozens of columns.

    Turn the data into a Table and then use ragulduy's formula. Sure that'll be much quicker.

    Regards, TMS

+ 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. [SOLVED] Data Validation reset only works one row at a time
    By Stphne38 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-12-2013, 09:35 AM
  2. Data validation - works with TAB or ENTER, errors from a Mouse Click
    By Buzz83 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-15-2013, 08:38 AM
  3. Return validation properties in the selectionchange event
    By js8765 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2010, 04:56 AM
  4. Replies: 3
    Last Post: 12-30-2008, 12:36 PM
  5. [SOLVED] Check validation on SelectionChange
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2006, 01:10 PM

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