Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Validation is not working

I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Validation is not working

If Target.Value = Range("$B$3").Value Then

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Validation is not working

Still no message box :(

"Gary Keramidas" wrote:

If Target.Value = Range("$B$3").Value Then

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Validation is not working

it works here, did you try pasting your code on the sheet code module of a clean
workbook?

--


Gary


"David" wrote in message
...
Still no message box :(

"Gary Keramidas" wrote:

If Target.Value = Range("$B$3").Value Then

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever
comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Validation is not working

Hi David,

Following seems to work :

Set Target = Range("$H$3")
If Target.Value = Range("$B$3").Value Then
MsgBox "That Entry is NOT ALLOWED!"
Target.ClearContents
Target.Select
End If

HTH
Cheers
Carim



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Validation is not working

i probably should ask, no offense, but do you have the code on the sheet module
of the sheet you're entering your values into, and not it a standard code
module?

--


Gary


"David" wrote in message
...
Still no message box :(

"Gary Keramidas" wrote:

If Target.Value = Range("$B$3").Value Then

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever
comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Validation is not working

I closed and saved the workbook, reopened it and it worked the first time. I
made another change and nothing. Made several more changes, and nothing.

"Gary Keramidas" wrote:

If Target.Value = Range("$B$3").Value Then

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Validation is not working

David,

For your new tests, make sure

Application.EnableEvents = True

is on ...

HTH
Carim

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Validation is not working

try this in place of your code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$H$3" Then
Set rng = Range("B3")
If Target.Value = rng Then
MsgBox "That Entry is NOT ALLOWED!"
End If

End If
End Sub

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Validation is not working

Geez....I'm just getting nothing. I have the number 20 in B3 and try a bunch
of numbers in H3...and just nothing. VERY WEIRD! I even put the code on a
clean worksheet and still nothing. Here is the full code again I'm using:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
Set Target = Range("$H$3")
If Target.Value = Range("$B$3").Value Then
MsgBox "That Entry is NOT ALLOWED!"
Target.ClearContents
Target.Select
End If
ws_exit:
Application.EnableEvents = True
End Sub

"Carim" wrote:

Hi David,

Following seems to work :

Set Target = Range("$H$3")
If Target.Value = Range("$B$3").Value Then
MsgBox "That Entry is NOT ALLOWED!"
Target.ClearContents
Target.Select
End If

HTH
Cheers
Carim




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Validation is not working

I just got rid of both application event code lines and working fine now.
Thanks SO much!!

"Carim" wrote:

David,

For your new tests, make sure

Application.EnableEvents = True

is on ...

HTH
Carim


  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Validation is not working

Thank you very much. That works as well!

"Gary Keramidas" wrote:

try this in place of your code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$H$3" Then
Set rng = Range("B3")
If Target.Value = rng Then
MsgBox "That Entry is NOT ALLOWED!"
End If

End If
End Sub

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub




  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default Validation is not working

Searching found this close. Want to require entry into each cell in row not
allow blanks. Like the msgbox idea. Does not sound so demanding but gets the
job done.
will play with this and hopeing.
Thanks

"Gary Keramidas" wrote:

try this in place of your code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$H$3" Then
Set rng = Range("B3")
If Target.Value = rng Then
MsgBox "That Entry is NOT ALLOWED!"
End If

End If
End Sub

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell is
equal to or greater than the value in another cell, but no MsgBox ever comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub




  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Validation is not working

the change event only fires when someone edits a cell. It seems unlikely
someone will edit a cell and leave it blank.

In the code I sent you I did put a cursory check to identify if there are
any blanks in column L before the current entry.

--
Regards,
Tom Ogilvy



"Curt" wrote in message
...
Searching found this close. Want to require entry into each cell in row
not
allow blanks. Like the msgbox idea. Does not sound so demanding but gets
the
job done.
will play with this and hopeing.
Thanks

"Gary Keramidas" wrote:

try this in place of your code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$H$3" Then
Set rng = Range("B3")
If Target.Value = rng Then
MsgBox "That Entry is NOT ALLOWED!"
End If

End If
End Sub

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell
is
equal to or greater than the value in another cell, but no MsgBox ever
comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub






  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default Validation is not working

Yes what you sent is working fine.
This is an after thought. What I inherited from the last person was missing
data in the rows. Some entries have had to be scraped for this lack of data.
My valadation idea was to require a user to not leave any blanks in row.
Tried to do this with excel valadation on sheet no avail. Seems the more I
work on this the more I find that is needed. Most of data entry is done by
trainees at the centre. Most are having a hard time readjusting. My drive is
to make it a little easier for them.
Hope you can understand my passion for this. Also can excuse my lack of
experience in doing this. Not as Not as mean But still a Semper Fi
Added this as the help is great.
Thanks


"Tom Ogilvy" wrote:

the change event only fires when someone edits a cell. It seems unlikely
someone will edit a cell and leave it blank.

In the code I sent you I did put a cursory check to identify if there are
any blanks in column L before the current entry.

--
Regards,
Tom Ogilvy



"Curt" wrote in message
...
Searching found this close. Want to require entry into each cell in row
not
allow blanks. Like the msgbox idea. Does not sound so demanding but gets
the
job done.
will play with this and hopeing.
Thanks

"Gary Keramidas" wrote:

try this in place of your code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$H$3" Then
Set rng = Range("B3")
If Target.Value = rng Then
MsgBox "That Entry is NOT ALLOWED!"
End If

End If
End Sub

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a cell
is
equal to or greater than the value in another cell, but no MsgBox ever
comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub








  #16   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Validation is not working

Data validation only reacts to what a user enters. It can't force the user
to make an entry.

You would have to figure out the minimum everything that the user must do,
then figure out when to check to see if they did it.

If I I made an entry in one cell, then saved and closed the workbook.

If I made an entry in one cell and walked away. The next person starts
entering data and that triggers an event that locks up the sheet because of
the first persons action (no way to say an entry in a cell is incorrect
until some subsequent events makes it appear so).

So you see the complexity that could be involved. That is why many people
put up userforms to get data and populate sheets and don't give the data
entry people access to the sheet. Others just have people instruct/train
the people entering the data and manually check them after.

--
regards,
Tom Ogilvy





"Curt" wrote in message
...
Yes what you sent is working fine.
This is an after thought. What I inherited from the last person was
missing
data in the rows. Some entries have had to be scraped for this lack of
data.
My valadation idea was to require a user to not leave any blanks in row.
Tried to do this with excel valadation on sheet no avail. Seems the more I
work on this the more I find that is needed. Most of data entry is done by
trainees at the centre. Most are having a hard time readjusting. My drive
is
to make it a little easier for them.
Hope you can understand my passion for this. Also can excuse my lack of
experience in doing this. Not as Not as mean But still a Semper Fi
Added this as the help is great.
Thanks


"Tom Ogilvy" wrote:

the change event only fires when someone edits a cell. It seems unlikely
someone will edit a cell and leave it blank.

In the code I sent you I did put a cursory check to identify if there are
any blanks in column L before the current entry.

--
Regards,
Tom Ogilvy



"Curt" wrote in message
...
Searching found this close. Want to require entry into each cell in row
not
allow blanks. Like the msgbox idea. Does not sound so demanding but
gets
the
job done.
will play with this and hopeing.
Thanks

"Gary Keramidas" wrote:

try this in place of your code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$H$3" Then
Set rng = Range("B3")
If Target.Value = rng Then
MsgBox "That Entry is NOT ALLOWED!"
End If

End If
End Sub

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a
cell
is
equal to or greater than the value in another cell, but no MsgBox
ever
comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub








  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default Validation is not working

Thank You for the knowledge about input Will work around it . Now I know.
Thanks Again

"Tom Ogilvy" wrote:

Data validation only reacts to what a user enters. It can't force the user
to make an entry.

You would have to figure out the minimum everything that the user must do,
then figure out when to check to see if they did it.

If I I made an entry in one cell, then saved and closed the workbook.

If I made an entry in one cell and walked away. The next person starts
entering data and that triggers an event that locks up the sheet because of
the first persons action (no way to say an entry in a cell is incorrect
until some subsequent events makes it appear so).

So you see the complexity that could be involved. That is why many people
put up userforms to get data and populate sheets and don't give the data
entry people access to the sheet. Others just have people instruct/train
the people entering the data and manually check them after.

--
regards,
Tom Ogilvy





"Curt" wrote in message
...
Yes what you sent is working fine.
This is an after thought. What I inherited from the last person was
missing
data in the rows. Some entries have had to be scraped for this lack of
data.
My valadation idea was to require a user to not leave any blanks in row.
Tried to do this with excel valadation on sheet no avail. Seems the more I
work on this the more I find that is needed. Most of data entry is done by
trainees at the centre. Most are having a hard time readjusting. My drive
is
to make it a little easier for them.
Hope you can understand my passion for this. Also can excuse my lack of
experience in doing this. Not as Not as mean But still a Semper Fi
Added this as the help is great.
Thanks


"Tom Ogilvy" wrote:

the change event only fires when someone edits a cell. It seems unlikely
someone will edit a cell and leave it blank.

In the code I sent you I did put a cursory check to identify if there are
any blanks in column L before the current entry.

--
Regards,
Tom Ogilvy



"Curt" wrote in message
...
Searching found this close. Want to require entry into each cell in row
not
allow blanks. Like the msgbox idea. Does not sound so demanding but
gets
the
job done.
will play with this and hopeing.
Thanks

"Gary Keramidas" wrote:

try this in place of your code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$H$3" Then
Set rng = Range("B3")
If Target.Value = rng Then
MsgBox "That Entry is NOT ALLOWED!"
End If

End If
End Sub

--


Gary


"David" wrote in message
...
I am trying to get a MsgBox to pop up if the value entered into a
cell
is
equal to or greater than the value in another cell, but no MsgBox
ever
comes
up. The code is in the sheet I'm working on. Help!

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$3" Then
If Target.Value = "$B$3" Then
MsgBox "That Entry is NOT ALLOWED!"
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub









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
2007 data validation not working ker_01 Excel Discussion (Misc queries) 1 October 28th 09 07:31 PM
Validation From List Not Working Erin Searfoss Excel Discussion (Misc queries) 4 August 8th 09 12:36 AM
Validation problem with list 2 working kit Excel Discussion (Misc queries) 2 September 13th 07 12:18 AM
Data Validation not working!! Please help!!!! [email protected] Excel Discussion (Misc queries) 13 April 19th 07 12:08 PM
Data Validation Not Working Brett Excel Discussion (Misc queries) 6 March 19th 05 01:12 PM


All times are GMT +1. The time now is 06:32 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"