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


colofnature Wrote:
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


Col


Hi Colofnature,

I received an error message saying that Object Required in
If Target.Address(True, True) = "$A$1" Then
would you know how to correct this?
anyway im just using the visual basic editor in MS Excel

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