#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Text box

Hi

I have inserted a text box into my excel spreadsheet.
I've set it to use the enter key to move to the next line and set it to
have multiple lines.
Is there a way to limit the number of lines a user can fill?

I know you can set character limits...but I need to set line limits so that
the entire box is shown when printed...and I can set it to grow bigger...as
my sheet needs to fit on one page when printed

Thanks in advance for your help!!!
Kimberly


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Text box

Kimberly,

A very crude way of doing it as follows:

Private Sub TextBox1_Change()
Const cMaxLines = 5
Dim lngSelStart As Long, strTemp As String, i As Long, j As Long,
lngTextLen As Long

With TextBox1
If .LineCount cMaxLines Then
lngSelStart = .SelStart
j = .LineCount - cMaxLines
strTemp = .Text
lngTextLen = Len(strTemp)
For i = lngTextLen To 1 Step -1
If Mid(strTemp, i, 1) = vbLf Then
j = j - 1
If j = 0 Then
.Text = Mid(strTemp, 1, i - 2)
.SelStart = lngSelStart
Exit For
End If
End If
Next
End If
End With
End Sub

Rob

"KimberlyC" wrote in message
...
Hi

I have inserted a text box into my excel spreadsheet.
I've set it to use the enter key to move to the next line and set it to
have multiple lines.
Is there a way to limit the number of lines a user can fill?

I know you can set character limits...but I need to set line limits so

that
the entire box is shown when printed...and I can set it to grow

bigger...as
my sheet needs to fit on one page when printed

Thanks in advance for your help!!!
Kimberly




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Text box

Thanks!
That did the trick!!
"Rob van Gelder" wrote in message
...
Kimberly,

A very crude way of doing it as follows:

Private Sub TextBox1_Change()
Const cMaxLines = 5
Dim lngSelStart As Long, strTemp As String, i As Long, j As Long,
lngTextLen As Long

With TextBox1
If .LineCount cMaxLines Then
lngSelStart = .SelStart
j = .LineCount - cMaxLines
strTemp = .Text
lngTextLen = Len(strTemp)
For i = lngTextLen To 1 Step -1
If Mid(strTemp, i, 1) = vbLf Then
j = j - 1
If j = 0 Then
.Text = Mid(strTemp, 1, i - 2)
.SelStart = lngSelStart
Exit For
End If
End If
Next
End If
End With
End Sub

Rob

"KimberlyC" wrote in message
...
Hi

I have inserted a text box into my excel spreadsheet.
I've set it to use the enter key to move to the next line and set it to
have multiple lines.
Is there a way to limit the number of lines a user can fill?

I know you can set character limits...but I need to set line limits so

that
the entire box is shown when printed...and I can set it to grow

bigger...as
my sheet needs to fit on one page when printed

Thanks in advance for your help!!!
Kimberly






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
Using TEXT and &TEXT - display numbers with commas, underline text Gary Excel Discussion (Misc queries) 3 May 5th 23 03:46 AM
Sumif text is contained winthin a longer text string in a cell Johnny M[_2_] Excel Worksheet Functions 3 March 21st 07 02:50 PM
Text does not display in "Text boxs" and when wrapping text in a c Esteban Excel Discussion (Misc queries) 1 March 8th 07 11:59 PM
want to remove all text characters equal to one character in length from text string [email protected] Excel Worksheet Functions 1 April 18th 05 09:56 PM
extracting text from within a cell - 'text to rows@ equivalent of 'text to columns' Dan E[_2_] Excel Programming 4 July 30th 03 06:43 PM


All times are GMT +1. The time now is 07:48 AM.

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"