Prev: Excel Formulas
Next: Date + relative number reference
From: Tim on 26 Apr 2010 05:17 I have created a text box but I want the text length to be equal to or less than 600 words. How do I do that in Excel 2003 please
From: Gary Brown on 26 Apr 2010 10:49 Assuming you are using the 'Control Toolbox' textbox, in the worksheet module that the textbox is located [assuming the name of the textbox is TextBox1], put... Private Sub TextBox1_Change() If Len(TextBox1.Value) > 600 Then TextBox1.Value = Left(TextBox1.Value, 600) End If End Sub -- Hope this helps. If it does, please click the Yes button. Thanks in advance for your feedback. Gary Brown "Tim" wrote: > I have created a text box but I want the text length to be equal to or less > than 600 words. > How do I do that in Excel 2003 please
From: Gary Brown on 26 Apr 2010 11:05 OOPS!!! Read your request incorrectly. I first read it as 600 letters. Here's the correct answer for word count... Private Sub TextBox1_Change() Dim iWordCount As Integer iWordCount = 600 If Len(TextBox1.Value) - Len(Application.WorksheetFunction. _ Substitute(TextBox1.Value, " ", "")) > iWordCount - 1 Then TextBox1.Value = _ Left(TextBox1.Value, Application.WorksheetFunction. _ Find("~", Application.WorksheetFunction. _ Substitute(TextBox1.Value, " ", "~", iWordCount - 1))) End If End Sub -- Hope this helps. If it does, please click the Yes button. Thanks in advance for your feedback. Gary Brown "Tim" wrote: > I have created a text box but I want the text length to be equal to or less > than 600 words. > How do I do that in Excel 2003 please
|
Pages: 1 Prev: Excel Formulas Next: Date + relative number reference |