+ Reply to Thread
Results 1 to 7 of 7

Cell to retain a default value when it is cleared/deleted

  1. #1
    Registered User
    Join Date
    02-17-2009
    Location
    irving
    MS-Off Ver
    Excel 2007
    Posts
    5

    Cell to retain a default value when it is cleared/deleted

    Hi,

    I am currently working on a excel sheet which will be used by a multiple users. My problem is
    I want to have a cell say A1, which has a text say "Enter Name". When a user tries to enter his name the cell will chage to the name he enters. Let us assume that the user entered his name "Mani". Now A1 has the value "Mani".
    If I delete/clear the value of A1, I want it to retain the value "Enter Name" automatically. Can this be possible?

    thanks in advance.
    Last edited by mani_v23; 11-16-2009 at 07:21 PM.

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

    Re: Cell to retain a default value when it is cleared/deleted

    Yes, but it will require the use of VBA. That means everyone who uses the workbook will have to enable macros. Are there any other macros already in this workbook? If not, then this would be a notable change. If so, then it's not big deal.

    Here's a macro that would do it:
    Please Login or Register  to view this content.
    How to use the macro:

    1. Open up your workbook
    2. Right-click on the sheet tab
    3. Select VIEW CODE from the popup context menu
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The macro is installed and ready to use.
    ========

    Now make changes to cell A1 and watch what happens.

    You will have to save the workbook as a macro-enabled (*.xlsm) file.

  3. #3
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Cell to retain a default value when it is cleared/deleted

    JB,

    Why not narrow down the $A$1 with intersect(Target,Range("A1"))

    Maybe someone has selected the complete column and uses CTRL+Enter to fill it.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  4. #4
    Forum Guru teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,364

    Re: Cell to retain a default value when it is cleared/deleted

    Errmmm.... maybe reserve one cell for the label "Enter name" and enter the actual data in the adjacent cell. Just like any old form....

  5. #5
    Registered User
    Join Date
    02-17-2009
    Location
    irving
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Cell to retain a default value when it is cleared/deleted

    Thanks a lot for the quick reply.

    It worked like a charm

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

    Re: Cell to retain a default value when it is cleared/deleted

    Quote Originally Posted by rwgrietveld View Post
    JB,

    Why not narrow down the $A$1 with intersect(Target,Range("A1"))

    Maybe someone has selected the complete column and uses CTRL+Enter to fill it.
    Personal preference. I use the intersect method, too. It's not any better, it's just different.

    My suggestion will accurately evaluate cell A1 regardless of how many cells were selected and edited at the same time. If they delete the entire column, A1 will fill itself back in.

    Yes, there are about 5 different ways to do this, I offered one. Sometimes one is enough.

  7. #7
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Cell to retain a default value when it is cleared/deleted

    My point is the fact that your code checks ALL cells in the Target range. If an entire row/column is selected this might take a while.

+ 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