+ Reply to Thread
Results 1 to 9 of 9

Force a default value in certain cells if the user trys to leave them blank

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Force a default value in certain cells if the user trys to leave them blank

    Hi,

    I am trying to force a default value of "Not Selected" into cells that have dropdown lists, because rather annoyingly, it is still possible to accidently delete the contents of the cell on the keyboard and press enter, leaving the cell blank.

    If anyone knows a better approach than what I am taking then please do let me know. Otherwise then please help me build on this code

    I have done this to force a certain cell to a default value if you try to leave it blank...

    Please Login or Register  to view this content.

    I want to make it so that it will apply to multiple cells on a worksheet but not ones that are joined together in a range, instead certain cells scattered about across the worksheet. Also how to do this in a way where you can just add or remove individual cells in an array or something in a line of code to alter what cells are included with just a minor adjustment to the code?


    Many thanks in advance for any assistance

    Regards,

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Force a default value in certain cells if the user trys to leave them blank

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Your code only works on $A$7 ??
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Force a default value in certain cells if the user trys to leave them blank

    Change the drop down list cells to suit.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Re: Force a default value in certain cells if the user trys to leave them blank

    Yes exactly, the code only works on A7, I could repeat it over and over for other cells of course but that seams very inefficient.

    I have attached an example, there are dropdown lists and for the one in A7, if you try selecting it and then delete with the keyboard and press enter, it will revert back to say "Not Selected". I would like the apply the same to others scattered about across the worksheet.

    Is the vba the only way to do this and if so, is there a way to do the code effectively so that cells can just be added or removed from a list in the code to include them?
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Re: Force a default value in certain cells if the user trys to leave them blank

    Also what if you wanted to force the cell value to remain the last item from the list that was selected if you tried to delete it and press enter with it blank, is there a way to do that?

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Force a default value in certain cells if the user trys to leave them blank

    See post #3

  7. #7
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Re: Force a default value in certain cells if the user trys to leave them blank

    Hi AlphaFrog,

    Yes that is very helpful thank you, exactly what I meant

    Are you also able to help with my question in post #5 ? Its kind of an extension to my original question.

    Want to try and make the value in the dropdown box remain the same as what it was if you try to delete it and press enter

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Force a default value in certain cells if the user trys to leave them blank

    Quote Originally Posted by D.Lovell View Post
    Want to try and make the value in the dropdown box remain the same as what it was if you try to delete it and press enter
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Re: Force a default value in certain cells if the user trys to leave them blank

    Yes that works exactly as I meant but screen flickers very noticeably unfortunately... Probably the undo I guess, tried turning off screen updating but it didn't make any difference. Anyway got what I need for now, your posts were very helpful thank you

+ 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. Replies: 3
    Last Post: 02-09-2015, 09:00 AM
  2. IF Statement to leave cell blank if multiple cells are all blank
    By sweeteri in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-14-2014, 12:02 PM
  3. Replies: 4
    Last Post: 06-24-2013, 07:17 AM
  4. Replies: 5
    Last Post: 05-29-2013, 12:27 AM
  5. Conditonal formating- leave blank cells blank
    By Devoneous1 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-02-2013, 09:38 PM
  6. Making MonthView default to today's date or leave blank
    By raehippychick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2008, 11:30 AM
  7. Replies: 4
    Last Post: 07-15-2008, 01:42 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