Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

validate when user leaves from a cell

  Asked By: Josefina    Date: Sep 20    Category: MS Office    Views: 652
  

I'm new in VBA and I need some help with some programming I'm trying
to do in Excel.

Basically, I need to write some code which will check to see whether
the user actually typed in some text in the cells that belong to
column D. Here's what I've done with some help from the web, however
this is not working as I would like it to work: in the following
code, the validation is done when the user ENTERS the cell, not when
he LEAVES from it. I need it to be the other way round, so can you
give me some help on how can I change that??


Code:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False

If Not Intersect(Target, Me.Range("D1:D1000")) Is Nothing Then

With Target
If .Value = "" Then

MsgBox ("Field is mandatory!")

End If

End With

End If

ws_exit:
Application.EnableEvents = True
End Sub

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on validate when user leaves from a cell Or get search suggestion and latest updates.




Tagged: