Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using TEXT and &TEXT - display numbers with commas, underline text | Excel Discussion (Misc queries) | |||
Sumif text is contained winthin a longer text string in a cell | Excel Worksheet Functions | |||
Text does not display in "Text boxs" and when wrapping text in a c | Excel Discussion (Misc queries) | |||
want to remove all text characters equal to one character in length from text string | Excel Worksheet Functions | |||
extracting text from within a cell - 'text to rows@ equivalent of 'text to columns' | Excel Programming |