Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Disallow Continuous String of same Character

I want users to enter an explanation of cost variances if they exist in a
Note box. Currently I force this by checking the length of text input into
this box (say B10) if the cost variance (say in A1) exceeds a certain
amount. But is it possible to disallow from input if the text is a
continuous string of the same character eg xxxxxx or AAAAAA. Some employees
have worked it out that the Text box only requires a minimum of 10
characters in length so they just enter xxxxx (10 times) etc

Thanks



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Disallow Continuous String of same Character

John,

"John" wrote in message
...
I want users to enter an explanation of cost variances if they exist in a
Note box. Currently I force this by checking the length of text input into
this box (say B10) if the cost variance (say in A1) exceeds a certain
amount. But is it possible to disallow from input if the text is a
continuous string of the same character eg xxxxxx or AAAAAA. Some employees
have worked it out that the Text box only requires a minimum of 10
characters in length so they just enter xxxxx (10 times) etc


Yes, you could do this, but you'd only be controlling one symptom of the
underlying problem - the users are not entering relevant data, and you want
them to. If a user figures out that he/she can't enter "AAAAAAAAAA", the
next try will probably be 0123456789. <g

If you have a finite list of cost variance explanations, it may be best to
store that list in a hidden worksheet, then use a dropdown or data
validation to force the user to select one of the explanations for each line
that has a cost variance.

That said, here's how you could check for a string of length =10 that
repeats the same character:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim sChar As String

With TextBox1
If Len(.Text) < 10 Then
MsgBox "Invalid entry."
Cancel = True
Else
sChar = Left$(.Text, 1)
If StrComp(.Text, String(Len(.Text), sChar)) = 0 Then
MsgBox "Nice try."
Cancel = True
End If
End If
End With
End Sub

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


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
Excel-Match 1st text character in a string to a known character? bushlite Excel Worksheet Functions 2 January 15th 07 06:36 PM
how to add character zero in text string Svemir Excel Programming 2 October 21st 05 07:51 AM
Function to return Character Position of Xth character within a string Andibevan[_2_] Excel Programming 4 June 9th 05 03:24 PM
Add to a string to make it continuous Adam Excel Programming 11 April 24th 05 02:06 PM
Checking to see whether a string contains a certain character ajitpalsingh200[_21_] Excel Programming 1 November 26th 04 09:36 AM


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