Line continuation error

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

Hey guys


I am getting the error "Too many line continuations" when
I try to add another line. I have 24 line continuations
and when I try to add a 25th, I get the error. Does
anyone know a work around because it just so happens I was
able to get it to only 24 lines but in the future, I may
need 25 or more.


Thank you
Todd Huttenstine
 
Hi Todd,

Todd said:
I am getting the error "Too many line continuations" when
I try to add another line. I have 24 line continuations
and when I try to add a 25th, I get the error. Does
anyone know a work around because it just so happens I was
able to get it to only 24 lines but in the future, I may
need 25 or more.

IIRC, the limit on line continuations is 25, as you have found. Typically,
you can work around this fairly easily. For example, if you have a long SQL
statement like this:

sSQL = "SELECT ee.FirstName, ee.LastName " & _
"FROM dbo.tblEmployees ee WITH (NOLOCK) " & _
"WHERE ee.EEID IN (1, 2, 3, 4) " & _
"ORDER BY ee.LastName, ee.FirstName"

You could rewrite it as follows:

sSQL = "SELECT ee.FirstName, ee.LastName "
sSQL = sSQL & "FROM dbo.tblEmployees ee WITH (NOLOCK) "
sSQL = sSQL & "WHERE ee.EEID IN (1, 2, 3, 4) "
sSQL = sSQL & "ORDER BY ee.LastName, ee.FirstName"

Thus avoiding the line continuations. If you have a long IF statment with
many Ands and Ors, you can break those up into separate Booleans and And/Or
the resulting variables.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
You can generally avoid this problem by breaking your work
down into smaller chunks and then referring to the chunks.
A better answer would depend on what situation you are
using line continuation in (comments, code, etc.).

Where text is the too long, instead of:

YourAnswer = InputBox("Please provide lots and lots of
information that includes blah blah blah and on and on and
on until I've used every word in the dictionary and then
repeated those words until my throat is sore just thinking
about it and then and then and then.......... until I'm
done")

You might try:

Prompt1 = Please provide lots and lots......
Prompt2 = until I've used every word...........
Prompt3 = until I'm done.

YourAnswer = InputBox(Prompt1 & " " & Prompt2 & " " &
Prompt3)

tod
 
'Code below creates a procedure in module Sheet1
Dim VBCodeMod As CodeModule
Dim LineNum As Long

Set VBCodeMod = Workbooks
("RDFMTD.xls").VBProject.VBComponents("Sheet1").CodeModule
With VBCodeMod
LineNum = .CountOfLines + 1
.InsertLines LineNum, _
"Private Sub Worksheet_Change(ByVal Target As
Excel.Range)" & Chr(13) & _
"Dim Counter As Long" & Chr(13) & _
"Dim TargetAddress" & Chr(13) & _
"On Error Resume Next" & Chr(13) & _
"Counter = Application.WorksheetFunction.CountA(Worksheets
(1).Range(" & Chr(34) & "K:K" & Chr(34) & "))" & Chr(13) &
_
"TargetValue = Target.Value" & Chr(13) & _
"Target = UCase(Target)" & Chr(13) & _
"TargetAddress = Target.Address" & Chr(13) & _
"TACL = Left(Target.Address(, 0), InStr(Target.Address(,
0), " & Chr(34) & "$" & Chr(34) & ") - 1)" & Chr(13) & _
"If TACL = " & Chr(34) & "Z" & Chr(34) & " Then" & Chr(13)
& _
"Target.Offset(1, -15).Select" & Chr(13) & _
"Else" & Chr(13) & _
"Set myRange = Intersect(Range(" & Chr(34) & "K2:K" & Chr
(34) & "& Counter), Target)" & Chr(13) & _
"If TargetValue = " & Chr(34) & "y" & Chr(34) & " Or
TargetValue = " & Chr(34) & "Y" & Chr(34) & " Then" & Chr
(13) & _
"Target.Offset(1, 0).Select" & Chr(13) & _
"Exit Sub" & Chr(13) & _
"Else" & Chr(13) & _
"End If" & Chr(13) & _
"If Not myRange Is Nothing Then" & Chr(13) & _
"Target.Offset(0, 15).Select" & Chr(13) & _
"SendKeys " & Chr(34) & "%{down}" & Chr(34) & Chr(13) & _
"End If" & Chr(13) & _
"End If" & Chr(13) & _
"End Sub"
End With
'-------------------------------------

Above is my code. It adds lines of code inside a module.
If I need to add more lines to the module I am adding
lines to by using this code, which in turn will mean I
need to add more lines of code to this code (code above),
would I be able to do this?
 
Split your long string into two or more substrings; then concatenate the
substrings:

substr1 = ..........
substr2 = ..........

..InsertLines LineNum, substr1 & substr2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Line continuation. 1
Software Life Cycle 3
Workbook Open event 1
Debug Error 3
Add Workbook with specified name 2
Selecting a listbox item event 3
Excel Version 3
Function variables 7

Back
Top