A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

limit comments to only 600 words



 
 
Thread Tools Display Modes
  #1  
Old April 26th, 2010, 10:17 AM posted to microsoft.public.excel.worksheet.functions
Tim
external usenet poster
 
Posts: 780
Default limit comments to only 600 words

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
Ads
  #2  
Old April 26th, 2010, 03:49 PM posted to microsoft.public.excel.worksheet.functions
Gary Brown[_6_]
external usenet poster
 
Posts: 61
Default limit comments to only 600 words

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

  #3  
Old April 26th, 2010, 04:05 PM posted to microsoft.public.excel.worksheet.functions
Gary Brown[_6_]
external usenet poster
 
Posts: 61
Default limit comments to only 600 words

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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2004-2018 OfficeFrustration.
The comments are property of their posters.