Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to be able to control the text length in either a cell or in a group
of merged cells (i.e. E22:G24, but merged). Data Validation doesn't return an error message until you hit the enter button. I would like something to return an error message if, for example, the maximum length is 20, then when the 21st character is hit, the message box pops up. Is this possible? -- Sandy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't believe you can do that. VB is suspended while a cell is in edit
mode. Once the contents has been "Entered", then VB can deal with it. Until then, Excel considers the cell empty. Mike F "Sandy" wrote in message ... I need to be able to control the text length in either a cell or in a group of merged cells (i.e. E22:G24, but merged). Data Validation doesn't return an error message until you hit the enter button. I would like something to return an error message if, for example, the maximum length is 20, then when the 21st character is hit, the message box pops up. Is this possible? -- Sandy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use data validation for this. Go to Data/Validation and under
allow, pick text length. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Data Validation doesn't return an error message until you hit the enter
button. I would like something to return an error message if, for example, the maximum length is 20, then when the 21st character is hit, the message box pops up. -- Regards, Tom Ogilvy "jashburn13" wrote in message oups.com... You can use data validation for this. Go to Data/Validation and under allow, pick text length. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Sandy,
An idea, barely tested. Add an ActiveX Textbox to your sheet, properties BorderStyle = 1, maybe change the border colour, exit design mode. Don't worry about position, size and visible. Select E22 and type some long text, press Enter when done. Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) Dim s As String s = TextBox1.Text If Len(s) 5 Then TextBox1.Text = Left(s, 10) ' change 10 to 20 ElseIf KeyCode = 13 And Shift = 0 Then TextBox1.Visible = False Me.Range("$D$22").Activate Else Me.Range("$E$22").Value = s End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target(1).Address = "$E$22" Then With Target(1).MergeArea TextBox1.Left = .Left TextBox1.Width = .Width TextBox1.Height = .Height TextBox1.Top = .Top End With TextBox1.Text = Target(1).Value TextBox1.Visible = True TextBox1.Activate ElseIf TextBox1.Visible Then TextBox1.Visible = False End If End Sub Just a thought Regards, Peter T "Sandy" wrote in message ... I need to be able to control the text length in either a cell or in a group of merged cells (i.e. E22:G24, but merged). Data Validation doesn't return an error message until you hit the enter button. I would like something to return an error message if, for example, the maximum length is 20, then when the 21st character is hit, the message box pops up. Is this possible? -- Sandy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
cell text length conditional formatting - Excel 2003 | Excel Discussion (Misc queries) | |||
Summing a column based on the length of text in a cell in anothercolumn | Excel Worksheet Functions | |||
Zip Code Validation - length =5 or 9 | Excel Discussion (Misc queries) | |||
How do I set up a text cell in Excel with restricted length? | Excel Discussion (Misc queries) | |||
The text length versus the cell size... | Excel Programming |