Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Add a limit of 140 characters to any cell

I am try to limit any cell(s) to 140 characters when typing and show a value
meaning counter as I type to let me know how many characters I have remain in
that cell. Could anyone help me on how I do this. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Add a limit of 140 characters to any cell

Excel cannot count letters as you type them.

You could do this with Data Validation.

The only problem with Data Validation is that you get an error message and
you have to re-type or edit.

You could set up event code to truncate anything over a certain number of
characters after user hits ENTER key

No message, no retyping/editing. If less than 140 no action. If greater
than 140, code cuts length to 140.

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:A10" 'edit to suit
' "A1,A2,B1,C5,C6" for a non-contiguous range example
Dim cell As Range

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Len(.Value) 140 Then
.Value = Left(.Value, 140)
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste into that module, Edit the range to suit. Alt + q to return to
the Excel window.


Gord Dibben MS Excel MVP

On Thu, 1 Oct 2009 15:39:05 -0700, Imperial
wrote:

I am try to limit any cell(s) to 140 characters when typing and show a value
meaning counter as I type to let me know how many characters I have remain in
that cell. Could anyone help me on how I do this. Thanks


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
Cell limit of characters Kaylen Excel Discussion (Misc queries) 4 October 23rd 08 11:53 PM
How to limit cell to 30 characters or less Gretta Excel Discussion (Misc queries) 2 March 21st 07 08:05 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 05:18 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"