Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Data validation with VBA

I have a cell that data put into it needs to be validated, with upper and
lower limits can't use data validation, it has to be VBA code). Need to
write click event which will control data input within the limits, for
example:
Input box can only accept between 15 and 75, any idea how to write the code.
Do while numbers ...........................


Loop

Thanks for your help


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Data validation with VBA

Who says you can't set upper and lower limits using Data
Validation?

Data Validation,
Allow: Custom,
Formula:

=AND(A1=15,A1<=75)

HTH
Jason
Atlanta, GA

-----Original Message-----
I have a cell that data put into it needs to be

validated, with upper and
lower limits can't use data validation, it has to be VBA

code). Need to
write click event which will control data input within

the limits, for
example:
Input box can only accept between 15 and 75, any idea how

to write the code.
Do while numbers ...........................


Loop

Thanks for your help


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Data validation with VBA

Here is some worksheet event code that traps the input. Put it in the
worksheet code module

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
If .Value < 15 Or .Value 75 Then
MsgBox "Invalid value"
.Value = ""
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"W. Adam" wrote in message
...
I have a cell that data put into it needs to be validated, with upper and
lower limits can't use data validation, it has to be VBA code). Need to
write click event which will control data input within the limits, for
example:
Input box can only accept between 15 and 75, any idea how to write the

code.
Do while numbers ...........................


Loop

Thanks for your help




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Data validation with VBA

"W. Adam" wrote:

I have a cell that data put into it needs to be validated, with upper and
lower limits can't use data validation, it has to be VBA code). Need to
write click event which will control data input within the limits, for
example:
Input box can only accept between 15 and 75, any idea how to write the code.



In VBA, you can use the Range's Validation object.

This is cleaner.

Regards,

John
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Data validation with VBA

"W. Adam" wrote:

I have a cell that data put into it needs to be validated, with upper and
lower limits can't use data validation, it has to be VBA code). Need to
write click event which will control data input within the limits, for
example:
Input box can only accept between 15 and 75, any idea how to write the code.
Do while numbers ...........................


In VBA, you can use the Range's Validation object.

This is cleaner.

Regards,

John
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
custom data validation on cells with data validation values AKrobbins Excel Worksheet Functions 2 June 21st 11 04:20 PM
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
data validation invalid in dynamic validation list ilia Excel Worksheet Functions 0 November 7th 06 12:54 PM
Data validation with validation lists and combo boxs Keith Excel Discussion (Misc queries) 1 October 12th 06 11:08 AM


All times are GMT +1. The time now is 03:32 PM.

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

About Us

"It's about Microsoft Excel"