Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
KKD KKD is offline
external usenet poster
 
Posts: 31
Default Cell Formats - Limit # of characters

I want to limit the # of characters allowed in a cell to 11, regardless of
what the user types in (less characters is fine). How can I do this?
--
KKD
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Cell Formats - Limit # of characters

Do you want a message telling user he has exceeded the 11 characters and
make him do it over?

Use Data ValidationText Length.

You can truncate automatically to 11 or less using event code.

No messages or do-overs.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim oval As String
On Error GoTo ws_exit:
Application.EnableEvents = False
oval = Target.Value
If oval = "" Then Exit Sub
If Not Intersect(Target, Columns("A")) Is Nothing Then
With Target
If Len(oval) 11 Then
.Value = Left(oval, 11)
End If
End With
End If
ws_exit:
Application.CutCopyMode = False
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Thu, 1 Apr 2010 15:01:01 -0700, KKD
wrote:

I want to limit the # of characters allowed in a cell to 11, regardless of
what the user types in (less characters is fine). How can I do this?


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
Add a limit of 140 characters to any cell Imperial Excel Discussion (Misc queries) 1 October 2nd 09 12:38 AM
Cell limit of characters Kaylen Excel Discussion (Misc queries) 4 October 23rd 08 11:53 PM
Can I limit a cell to 2 characters? Frankc Excel Discussion (Misc queries) 2 August 11th 05 01:03 AM
limit no of characters in cell rocket0612 Excel Discussion (Misc queries) 3 June 1st 05 07:11 PM
Can I limit a cell to 72 characters? How? Chris Excel Discussion (Misc queries) 2 December 28th 04 04:57 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"