Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Can I restrict a text column to a specific number of characters?

Is there a way in which I can restrict the number of characters entered in an
excel spreadsheet column, eg, maximum 50 characters.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Can I restrict a text column to a specific number of characters?

Hi,

Select the column then

data|Validation

From the drop down select 'Text Length' and set you Min and max values

Mike

"Irene Threadgold" wrote:

Is there a way in which I can restrict the number of characters entered in an
excel spreadsheet column, eg, maximum 50 characters.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default Can I restrict a text column to a specific number of characters?

Data/ Validation
--
David Biddulph

"Irene Threadgold" <Irene wrote in
message ...
Is there a way in which I can restrict the number of characters entered in
an
excel spreadsheet column, eg, maximum 50 characters.



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Can I restrict a text column to a specific number of character

Thank you very much

"Mike H" wrote:

Hi,

Select the column then

data|Validation

From the drop down select 'Text Length' and set you Min and max values

Mike

"Irene Threadgold" wrote:

Is there a way in which I can restrict the number of characters entered in an
excel spreadsheet column, eg, maximum 50 characters.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Can I restrict a text column to a specific number of characters?

The only problem with Data Validation is that you get an error message if
you exceed the 50 characters and you have to edit to get back to 50 or less.

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

No message, no editing.

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) 50 Then
.Value = Left(.Value, 50)
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, 5 Nov 2009 07:34:06 -0800, Irene Threadgold <Irene
wrote:

Is there a way in which I can restrict the number of characters entered in an
excel spreadsheet column, eg, maximum 50 characters.


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
Count the number of times specific text appears in a column Nannie Excel Worksheet Functions 5 August 27th 08 07:09 PM
Macro that returns a specific number of characters from a text str Jurassien Excel Discussion (Misc queries) 2 August 1st 07 11:14 PM
Finding cells with a specific number of characters Kamran Excel Discussion (Misc queries) 6 March 29th 06 11:04 PM
Text String - Specific Characters Kiser Excel Worksheet Functions 6 February 10th 06 02:43 AM
trim a string by specific number of characters windyoldman Excel Discussion (Misc queries) 2 July 13th 05 01:53 PM


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