PC Review


Reply
Thread Tools Rate Thread

Data Validation: Blank Cell Not Detected

 
 
Connie
Guest
Posts: n/a
 
      10th Oct 2006
I have a cell which I am validating with the data validation
functionality in Excel.

Tech_no, Code_List_Support, and Code_List_Technician are defined names
(the latter 2 are ranges).

The validation is that it must be a whole number with the following min
and max values:

Min =
IF(ISBLANK(Tech_No),MIN(Code_List_Support),MIN(Code_List_Technician))
Max =
IF(ISBLANK(Tech_No),MAX(Code_List_Support),MAX(Code_List_Technician))

I have the Ignore Blank Values UNCHECKED. However, when I tab over the
cell and leave the cell blank, I do not get an error message. I tried
hitting enter with the same result.

I'd like to make sure that the cell is not blank.

Any suggestions? Thanks.

 
Reply With Quote
 
 
 
 
Doug Glancy
Guest
Posts: n/a
 
      10th Oct 2006
Connie,

Unchecking "Ignore Blank" prevents the user from leaving cell-edit mode
without entering anything. However it doesn't prevent them from tabbing
through the cell or, for that matter, clearing or deleting the cell
contents. In other words, it only has effect when in cell-edit mode. As
far as I can tell from trying and Googling, there is no Data Validation that
does what you are looking for.

You might try a SelectionChange event in the worksheet module, like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static cell_before_selection As Range

If Not cell_before_selection Is Nothing Then
If cell_before_selection.Address = Range("A2").Address And
IsEmpty(Range("A2")) Then
Application.EnableEvents = False
Range("A2").Select
MsgBox "you must enter something here"
Application.EnableEvents = True
End If
End If
Set cell_before_selection = ActiveCell

End Sub

Of course that doesn't react if they clear a whole range and it includes
your cell, but it's not the ActiveCell, so I guess you could add this to the
worksheet module as well:

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo err_handler

Application.EnableEvents = False
If Not Intersect(Target, Range("A2")) Is Nothing Then
If IsEmpty(Range("A2")) Then
Range("A2").Select
MsgBox "you must enter something here"
End If
End If

err_handler:
Application.EnableEvents = True

It kind of begs the question of what if they never enter the cell.

You could also try conditional formatting to draw their attention to the
empty cell, or maybe a formula in a dependent cell that includes a message
if the cell is blank. Also, you could run code before closing the workbook
that checks the cell and insists that they enter something in it.

hth,

Doug


"Connie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a cell which I am validating with the data validation
> functionality in Excel.
>
> Tech_no, Code_List_Support, and Code_List_Technician are defined names
> (the latter 2 are ranges).
>
> The validation is that it must be a whole number with the following min
> and max values:
>
> Min =
> IF(ISBLANK(Tech_No),MIN(Code_List_Support),MIN(Code_List_Technician))
> Max =
> IF(ISBLANK(Tech_No),MAX(Code_List_Support),MAX(Code_List_Technician))
>
> I have the Ignore Blank Values UNCHECKED. However, when I tab over the
> cell and leave the cell blank, I do not get an error message. I tried
> hitting enter with the same result.
>
> I'd like to make sure that the cell is not blank.
>
> Any suggestions? Thanks.
>



 
Reply With Quote
 
Connie
Guest
Posts: n/a
 
      10th Oct 2006
Lots of great suggestions. Thanks! I will try the suggestions a little
later. I really appreciate your help.

Connie

Doug Glancy wrote:
> Connie,
>
> Unchecking "Ignore Blank" prevents the user from leaving cell-edit mode
> without entering anything. However it doesn't prevent them from tabbing
> through the cell or, for that matter, clearing or deleting the cell
> contents. In other words, it only has effect when in cell-edit mode. As
> far as I can tell from trying and Googling, there is no Data Validation that
> does what you are looking for.
>
> You might try a SelectionChange event in the worksheet module, like this:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> Static cell_before_selection As Range
>
> If Not cell_before_selection Is Nothing Then
> If cell_before_selection.Address = Range("A2").Address And
> IsEmpty(Range("A2")) Then
> Application.EnableEvents = False
> Range("A2").Select
> MsgBox "you must enter something here"
> Application.EnableEvents = True
> End If
> End If
> Set cell_before_selection = ActiveCell
>
> End Sub
>
> Of course that doesn't react if they clear a whole range and it includes
> your cell, but it's not the ActiveCell, so I guess you could add this to the
> worksheet module as well:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> On Error GoTo err_handler
>
> Application.EnableEvents = False
> If Not Intersect(Target, Range("A2")) Is Nothing Then
> If IsEmpty(Range("A2")) Then
> Range("A2").Select
> MsgBox "you must enter something here"
> End If
> End If
>
> err_handler:
> Application.EnableEvents = True
>
> It kind of begs the question of what if they never enter the cell.
>
> You could also try conditional formatting to draw their attention to the
> empty cell, or maybe a formula in a dependent cell that includes a message
> if the cell is blank. Also, you could run code before closing the workbook
> that checks the cell and insists that they enter something in it.
>
> hth,
>
> Doug
>
>
> "Connie" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have a cell which I am validating with the data validation
> > functionality in Excel.
> >
> > Tech_no, Code_List_Support, and Code_List_Technician are defined names
> > (the latter 2 are ranges).
> >
> > The validation is that it must be a whole number with the following min
> > and max values:
> >
> > Min =
> > IF(ISBLANK(Tech_No),MIN(Code_List_Support),MIN(Code_List_Technician))
> > Max =
> > IF(ISBLANK(Tech_No),MAX(Code_List_Support),MAX(Code_List_Technician))
> >
> > I have the Ignore Blank Values UNCHECKED. However, when I tab over the
> > cell and leave the cell blank, I do not get an error message. I tried
> > hitting enter with the same result.
> >
> > I'd like to make sure that the cell is not blank.
> >
> > Any suggestions? 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
how blank data validation cell after changing dependent cell? Ian Elliott Microsoft Excel Misc 5 16th Aug 2009 02:42 AM
Blank cell w/data validation & automatic fill in? Munchkin Microsoft Excel Programming 1 6th Jun 2009 04:22 PM
Data Validation - Drop down when cell is blank mcolson Microsoft Excel Discussion 1 5th Jan 2009 08:03 PM
Data Validation - Blank Cell Otto Moehrbach Microsoft Excel Misc 2 1st Jun 2004 06:54 PM
Data Validation to prevent a blank cell Bob Microsoft Excel Discussion 3 30th Apr 2004 10:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:32 AM.