Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Validating cell contentswhen leaving the cell...

Hi All,

I've been reading all the posts here to try to figure out what I
thought would be a simple issue. I would like to check the contents of
a cell when I tab out, arrow out or click on some other cell in the
worksheet after having entered some text. If the contents don't meet
certain validation criteria, I need to keep the user in the cell and
not allow movement to another cell. Data/Validation is too easy to
deafeat. I'm using VBA to do this.

Example: I enter "123abcdef" in a cell and than tab to the next cell.
The validation rule states a maximum of 6 charachters can be entered.
The result in this case should leave me in the cell and force me to
reduce the number of charachters to some number 6 or below.

I tried using the Change and the SelectionChange events but they only
seem partially work for my needs.

Can anyone help?

Thanks a lot,
Lakehills

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Validating cell contentswhen leaving the cell...

Lakehills,

I know you said you tried the Change event, but this seems like it does what
you want (assuming the cell is A1):

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Len(Target.Text) 6 Then
MsgBox "too long!"
Target.Select
End If
End If
End Sub

hth,

Doug

wrote in message
oups.com...
Hi All,

I've been reading all the posts here to try to figure out what I
thought would be a simple issue. I would like to check the contents of
a cell when I tab out, arrow out or click on some other cell in the
worksheet after having entered some text. If the contents don't meet
certain validation criteria, I need to keep the user in the cell and
not allow movement to another cell. Data/Validation is too easy to
deafeat. I'm using VBA to do this.

Example: I enter "123abcdef" in a cell and than tab to the next cell.
The validation rule states a maximum of 6 charachters can be entered.
The result in this case should leave me in the cell and force me to
reduce the number of charachters to some number 6 or below.

I tried using the Change and the SelectionChange events but they only
seem partially work for my needs.

Can anyone help?

Thanks a lot,
Lakehills



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
change cell data without leaving cell? George[_10_] Excel Discussion (Misc queries) 2 October 3rd 09 03:06 AM
Force required entry in cell before leaving that cell Retired Bill Excel Worksheet Functions 8 March 17th 09 10:57 PM
Validating a Cell Lady Success Excel Worksheet Functions 1 September 25th 08 06:05 PM
Validating certain cell Kasey Excel Worksheet Functions 0 August 17th 06 03:45 PM
Validating Cell ZAK Excel Programming 2 December 3rd 03 12:01 PM


All times are GMT +1. The time now is 06:51 PM.

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"