+ Reply to Thread
Results 1 to 6 of 6

VBA - Distinguishing when a cell is edited by a data validation list or free fromat text e

  1. #1
    Registered User
    Join Date
    03-17-2014
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    VBA - Distinguishing when a cell is edited by a data validation list or free fromat text e

    Hi All,

    Does anyone know of VBA code which can distinguish whether a cell has been edited by:

    selecting an option from a data validation list (DVL)
    or
    manually editing the text in a cell?

    The ""Show error alert after invalid data is entered"" option is unticked to allow both selection from the DVL as well as free format text entries.

    The problem arises when using the code below which makes an edited cell within a range display the new value as well as the prior value(s). This works well when using the DVL but not when editing the cell.

    Is there any code which can distinguish between the 2?

    Hope this makes sense, please let me know if anything requires further clarification.

    Many thanks in advance
    JLD



    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 03-20-2014 at 02:34 PM. Reason: added missing code tags, please read and follow the forum rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA - Distinguishing when a cell is edited by a data validation list or free fromat te

    There's more to that code, isn't there? A worksheet_selectionchange event, too?

    Meanwhile, I don't see any reason why that code doesn't work with manual entries, too. It does for me.
    Last edited by JBeaucaire; 03-20-2014 at 02:34 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    03-17-2014
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA - Distinguishing when a cell is edited by a data validation list or free fromat te

    Hi JBeaucaire,

    Thank you for your response. Your code works very well when selecting options from DVL's, free format text entries or a combination of the two but when you would like to edit a cell it can be quite tricky. For example, if you had 20 entries in a cell and at a later date wanted to delete one the code doesn't allow you to remove a selection.

    I think the only easy way to edit the cells for users (who will not know about VBA) would be to enter the 19 entries again or copy the contents into another cell, amend the selections and paste them back in.

    Is there an if statement that could amend the code?

    Also, do you know anyway to reorder the selections alphabetically once the cell is updated?

    Many Thanks
    JLD

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA - Distinguishing when a cell is edited by a data validation list or free fromat te

    On the DEveloper tab you could click the DESIGN MODE icon to turn off events so you can freely edit your cells without the event triggering, and then turn off Design Mode to set things working again.

  5. #5
    Registered User
    Join Date
    03-17-2014
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA - Distinguishing when a cell is edited by a data validation list or free fromat te

    Hi JBeaucaire,

    Problem solved, many thanks for your help, much appreciated!

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA - Distinguishing when a cell is edited by a data validation list or free fromat te

    I've marked this thread as SOLVED for you.
    Next time, select Thread Tools from the links above to mark a thread as SOLVED. Thanks.

+ 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 and Free Text
    By Kumara_faith in forum Excel General
    Replies: 4
    Last Post: 01-22-2015, 11:03 AM
  2. Replies: 4
    Last Post: 12-19-2013, 10:44 AM
  3. Allow Free Form with Double Validation List
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-09-2010, 02:14 PM
  4. [SOLVED] Stopping free text entry in validation cell
    By smf in forum Excel General
    Replies: 2
    Last Post: 12-15-2005, 03:50 PM
  5. text is deleted when cell is edited
    By GRIFFO in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-23-2005, 11:05 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