View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
colofnature[_91_] colofnature[_91_] is offline
external usenet poster
 
Posts: 1
Default Validation with Macro to count characters


Try this in the Worksheet's code module:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address(True, True) = "$A$1" Then
If Len(Target.Value) < 11 And Target.Value < Empty Then _
MsgBox "You have entered " & Abs(11 - Len(Target.Value)) & " too " _
& IIf(Len(Target.Value) 11, "many", "few") & " characters"
[a1].Select
End If
End Sub


Co

--
colofnatur
-----------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...fo&userid=3435
View this thread: http://www.excelforum.com/showthread.php?threadid=56278