Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Cell Restrictions

How do you restrict a cell so that only certain data can be entered?

For example: I need to protect a cell in a fashion that only a date can
be entered.

I'm having problems with people entering formulas in for the date and I
want to restrict them from doing this (it messes up everything).

Any help would be appreciated

thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Cell Restrictions

You want to add cell validationl. Select Data - Validation and in the drop
down list select the data type you want. On the other tabs you can define how
you would like to handle input errors...
--
HTH...

Jim Thomlinson


"SmartyPants" wrote:

How do you restrict a cell so that only certain data can be entered?

For example: I need to protect a cell in a fashion that only a date can
be entered.

I'm having problems with people entering formulas in for the date and I
want to restrict them from doing this (it messes up everything).

Any help would be appreciated

thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Cell Restrictions

I have a similar question.
How do you restrict a text or comobox control, on a user form, so that only
certain data can be entered?



"Jim Thomlinson" wrote:

You want to add cell validationl. Select Data - Validation and in the drop
down list select the data type you want. On the other tabs you can define how
you would like to handle input errors...
--
HTH...

Jim Thomlinson


"SmartyPants" wrote:

How do you restrict a cell so that only certain data can be entered?

For example: I need to protect a cell in a fashion that only a date can
be entered.

I'm having problems with people entering formulas in for the date and I
want to restrict them from doing this (it messes up everything).

Any help would be appreciated

thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Cell Restrictions


Jim Thomlinson wrote:
You want to add cell validationl. Select Data - Validation and in the drop
down list select the data type you want. On the other tabs you can define how
you would like to handle input errors...
--
HTH...

Jim Thomlinson


This almost works, except I don't see a way to restrict users from
entering the date in the form of a formula.

I restricted the cell to contain a date, but you can still enter the
formula =today().

This is the formula that is causing all my problems.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cell Restrictions

That was my thought when I read data validation as the suggested solution.

You would probably need to use an event macro, with the caution that if
macros are disabled, your protection evaporates. I assume by posting here
that you feel you need a macro and are familiar with macros.

right click on the sheet tab and select view code.

in the left dropdown at the top of the resulting module, select worksheet
and from the dropdown on the right of the resulting module select Change

Private Sub Private Sub Worksheet_Change(ByVal Target As Range)

End Sub

will be placed in the module (Make sure to use Change, not SelectionChange)

then add code like (below is untested pseudo code)

Private Sub Worksheet_Change(ByVal Target As Range)
if Target.count 1 then exit sub
on Error goto ErrHandler
if Target.Address = "$D$4" then
if target.hasformula then
application.EnableEvents = False
Target.clearcontents
Msgbox "No formulas please!"
end if
End if
ErrHandler:
Application.EnableEvents = True

End Sub

this only protect D4 as written. If you need to protect a variety of cells
with the same restrictions you could change the condition to

if not Interset(Target,Range("D2:D10,F4,G5,H3")) is nothing then

as an example.

--
Regards,
Tom Ogilvy


"SmartyPants" wrote:


Jim Thomlinson wrote:
You want to add cell validationl. Select Data - Validation and in the drop
down list select the data type you want. On the other tabs you can define how
you would like to handle input errors...
--
HTH...

Jim Thomlinson


This almost works, except I don't see a way to restrict users from
entering the date in the form of a formula.

I restricted the cell to contain a date, but you can still enter the
formula =today().

This is the formula that is causing all my problems.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cell Restrictions

there is no built in provision for this. You can use events like the change
event, afterupdate, or exit events to have your code check the entry and take
the appropriate action. Just note the change fires on every keystroke.

--
Regards,
Tom Ogilvy



"ernie" wrote:

I have a similar question.
How do you restrict a text or comobox control, on a user form, so that only
certain data can be entered?



"Jim Thomlinson" wrote:

You want to add cell validationl. Select Data - Validation and in the drop
down list select the data type you want. On the other tabs you can define how
you would like to handle input errors...
--
HTH...

Jim Thomlinson


"SmartyPants" wrote:

How do you restrict a cell so that only certain data can be entered?

For example: I need to protect a cell in a fashion that only a date can
be entered.

I'm having problems with people entering formulas in for the date and I
want to restrict them from doing this (it messes up everything).

Any help would be appreciated

thanks


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Cell Restrictions

thanks alot


"Tom Ogilvy" wrote:

there is no built in provision for this. You can use events like the change
event, afterupdate, or exit events to have your code check the entry and take
the appropriate action. Just note the change fires on every keystroke.

--
Regards,
Tom Ogilvy



"ernie" wrote:

I have a similar question.
How do you restrict a text or comobox control, on a user form, so that only
certain data can be entered?



"Jim Thomlinson" wrote:

You want to add cell validationl. Select Data - Validation and in the drop
down list select the data type you want. On the other tabs you can define how
you would like to handle input errors...
--
HTH...

Jim Thomlinson


"SmartyPants" wrote:

How do you restrict a cell so that only certain data can be entered?

For example: I need to protect a cell in a fashion that only a date can
be entered.

I'm having problems with people entering formulas in for the date and I
want to restrict them from doing this (it messes up everything).

Any help would be appreciated

thanks


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
RESTRICTIONS YESHWANT JOSHI Excel Discussion (Misc queries) 5 May 26th 09 05:02 PM
sumif with restrictions GfaCS Excel Worksheet Functions 7 September 21st 07 12:17 AM
Excel help and AD GPO restrictions javagirl Excel Discussion (Misc queries) 2 April 2nd 07 09:14 PM
How to do look up with restrictions JackR Excel Discussion (Misc queries) 3 April 3rd 06 01:12 AM
Excel Cell Restrictions sandy.cariappa Excel Worksheet Functions 1 May 27th 05 11:10 AM


All times are GMT +1. The time now is 11:07 AM.

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"