Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Jugglertwo
 
Posts: n/a
Default Don't allow a space in a cell...how to prevent?

One of my students asked an interesting question yesterday in Excel.
We were working on IF statements and if a cell had a student's name in it,
the IF statement proceeded to do the FALSE Result, if not, it did the TRUE
Result.
=if(A1="","student missed class","student attended class")
I explained that if a student hit the space bar and entered "a space", this
space would be considered something and the IF statement would produce the
FALSE Result of "student attended class".

Student's question (and mine): Is there a way to prevent someone from
entering "a space" in the cell? Even though it looks blank, the space will be
there causing the IF statement to produced "the wrong" result. Hope this
makes sense.

Any suggestions would be greatly appreciated!
Thanks!
Jugglertwo
  #2   Report Post  
Posted to microsoft.public.excel.misc
Ron Coderre
 
Posts: n/a
Default Don't allow a space in a cell...how to prevent?

You have more than one option he

1)You can prevent a space from appearing in any part of the cell by using
Data Validation:
Example:
Select Cell A1
DataData Validation
Allow: Custom
Formula: =NOT(ISNUMBER(SEARCH(" ",A1)))

2)You can also use Data Validation to prevent a space being the only
contents of the cell, but the user could type more than one space, right?

3)Alter your forumula to differentiate between BLANK and "".

=if(ISBLANK(A1),"student missed class","student attended class")


Do any of those help?

***********
Regards,
Ron


"Jugglertwo" wrote:

One of my students asked an interesting question yesterday in Excel.
We were working on IF statements and if a cell had a student's name in it,
the IF statement proceeded to do the FALSE Result, if not, it did the TRUE
Result.
=if(A1="","student missed class","student attended class")
I explained that if a student hit the space bar and entered "a space", this
space would be considered something and the IF statement would produce the
FALSE Result of "student attended class".

Student's question (and mine): Is there a way to prevent someone from
entering "a space" in the cell? Even though it looks blank, the space will be
there causing the IF statement to produced "the wrong" result. Hope this
makes sense.

Any suggestions would be greatly appreciated!
Thanks!
Jugglertwo

  #3   Report Post  
Posted to microsoft.public.excel.misc
bernard
 
Posts: n/a
Default Don't allow a space in a cell...how to prevent?

There may be a fancier way of doing it but one option is to
a) Fine a spare area in the spreadsheet and type a list of values you would
be happy for users to enter(e.g. Student missed class, Student Attended
class).
b) Highlight the range of cells that the values would normally be typed into
c) Select Data, Validation, Allow - select List from the drop down box, then
in the Source box highlight the list you created in a) above.

Hope this helps
Bernard

"Jugglertwo" wrote:

One of my students asked an interesting question yesterday in Excel.
We were working on IF statements and if a cell had a student's name in it,
the IF statement proceeded to do the FALSE Result, if not, it did the TRUE
Result.
=if(A1="","student missed class","student attended class")
I explained that if a student hit the space bar and entered "a space", this
space would be considered something and the IF statement would produce the
FALSE Result of "student attended class".

Student's question (and mine): Is there a way to prevent someone from
entering "a space" in the cell? Even though it looks blank, the space will be
there causing the IF statement to produced "the wrong" result. Hope this
makes sense.

Any suggestions would be greatly appreciated!
Thanks!
Jugglertwo

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
prevent blank cell Ken Stratford Excel Discussion (Misc queries) 0 March 26th 05 08:15 AM
How do I prevent Excel from plotting a cell w/ a formula as a "ze. Hatchet_Jack Charts and Charting in Excel 1 February 9th 05 10:31 PM
How do I prevent Excel from plotting a cell w/ a formula as a "ze. Bearclaw Chris Charts and Charting in Excel 0 February 9th 05 04:59 PM
prevent 4/5 in a cell automatically transfer to a date format kei Excel Discussion (Misc queries) 3 December 9th 04 11:52 AM


All times are GMT +1. The time now is 06:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"