PC Review


Reply
Thread Tools Rate Thread

Custom Data Validation via Code Q

 
 
Sean
Guest
Posts: n/a
 
      28th Apr 2007
I wish to create a formula via code that will do the following

As a Custom Data Validation in cell A1, if the value entered in A1 is
less than the value in A5, then return an error message etc, however
if the value in A5 is negative, then the value entered by user in A1
should be at least 0%

BTW value in A1 & A5 will be percent

Thanks

 
Reply With Quote
 
 
 
 
Coza
Guest
Posts: n/a
 
      28th Apr 2007
Something like below placed in the Sheet Code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value <> "" And Range("A5").Value <> "" And Range("A5").Value
> 0 And Range("A1").Value <= Range("A5").Value Then

MsgBox "The Value you entered into Cell A5 MUST be Greater than(or Equal to)
the Value in A5 !", vbCritical
Range("A1").Value = ""
Range("A1").Activate
Else
If Range("A1").Value <> "" And Range("A5").Value <> "" And Range("A5").Value
< 0 And Range("A1").Value < 0 Then
MsgBox "A5 is a Negative Number and Therefore A1 MUST be a Positive Number
!", vbCritical
Range("A1").Value = ""
Range("A1").Activate
End If
End If
End Sub

??


Corey....
"Sean" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I wish to create a formula via code that will do the following
>
> As a Custom Data Validation in cell A1, if the value entered in A1 is
> less than the value in A5, then return an error message etc, however
> if the value in A5 is negative, then the value entered by user in A1
> should be at least 0%
>
> BTW value in A1 & A5 will be percent
>
> Thanks
>



 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      28th Apr 2007
Set the validation to Custom and the formula is:
=(A1>MAX(A5,0))
--
Gary''s Student - gsnu200718


"Sean" wrote:

> I wish to create a formula via code that will do the following
>
> As a Custom Data Validation in cell A1, if the value entered in A1 is
> less than the value in A5, then return an error message etc, however
> if the value in A5 is negative, then the value entered by user in A1
> should be at least 0%
>
> BTW value in A1 & A5 will be percent
>
> Thanks
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
custom data validation on cells with data validation values AKrobbins Microsoft Excel Worksheet Functions 2 21st Jun 2011 04:20 PM
Custom Data Validation =?Utf-8?B?U3RldmUgRQ==?= Microsoft Excel Misc 1 2nd Sep 2006 10:16 PM
Re: Custom Data Validation Bernie Deitrick Microsoft Excel Worksheet Functions 1 9th Sep 2004 07:38 PM
How to use data validation - Custom validation 0-0 Wai Wai ^-^ Microsoft Excel Discussion 1 7th May 2004 09:04 PM
custom data validation Paul James Microsoft Excel Misc 9 24th Jan 2004 11:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:57 AM.