View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
jasonsweeney[_41_] jasonsweeney[_41_] is offline
external usenet poster
 
Posts: 1
Default Parsing out text entries in a text box

Thanks for the help. Answers: Yes, Xl2000 or better. Textbox = active
userform

The code is almost there, but two issues remain:
(1) spaces between words still are not counted as a "word", whil
spaces after periods are....
(2) There is an error generated by [plainttextbox.Text = Join(varr,
")] when the word count exceeds 21.

Here is what I have done with your code. I have a user form with
label named "wordcount".


__________________________________________
Private Sub go_Click()

Dim rng As Range
varr = Split(plaintextbox.Text, " ")
Set rng = Range("A1").Resize(UBound(varr, 1) - LBound(varr, 1) + 1, 1)
rng = Application.Transpose(varr)
For Each cell In rng
cell.Value = Application.Clean(cell.Value)
Next
UserForm1.Hide
_______________________________________
Private Sub plaintextbox_Change()
'
' spaces between words need to be counted as words in the
' word count. e.g. "See Spot Run" = 5 words
Dim varr
ReDim varr(0 To 1)
varr = Split(plaintextbox.Text, " ")
wordcount.Caption = UBound(varr)
If UBound(varr) - 1 = 14 Then
MsgBox "You are reaching the limit of 20 words"
ElseIf UBound(varr) - 1 = 20 Then
MsgBox "You have reached the limit of 20 words"
ReDim Preserve varr(0 To 19)
plainttextbox.Text = Join(varr, " ") '<-------------- creates erro
after 21 words
End I

--
Message posted from http://www.ExcelForum.com