Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XL2000: Prevent clearing cell with spacebar

Status
Not open for further replies.

locutis

Programmer
Nov 3, 2006
53
0
0
US
OK, here's one for you guys. How can you prevent a user from clearing a cell value with the spacebar? Is there a way to trap the event and throw an alert or simply disable the spacebar for that cell?

Thanks in advance,
Jean Luc
 



Hi,

Hitting the SPACE bar does NOT clear a cell.

A SPACE character has been entered in the cell, just like any other character.

It is a VERY VERY BAD HABIT to use the SPACE bar to "clear" a cell. Excel, rightly so, thinks that there is DATA in that cell and treats it as such. Since no one can SEE the SPACE character, ther's all sorts of problems that this can cause, like printing extra BLANK PAGES, which, of course, do have SPACE DATA on them

The best way to avoid this pitfall, is to train users to use Excel properly. Programmin could be done, but I would not recommend programming to avoid this bad habbit. In some cases, a SPACE might be necessary in a cell.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
If you just want to prevent users from being able to alter a cell (emptying data, replacing data with a space character or otherwise making changes), check out Tools > Protection > Protect Sheet.

If there are any cells that you want not protected, then select those cells and go to Format > Cells > Protection and uncheck Locked before turning on sheet protection.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
You could capture the keypress and direct it to an empty function (or an alert box). I'm not sure how to do it in VB, but in the macro language, use [tt]=ON.KEY(" ","MyMacro")[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top