tags:

views:

105

answers:

3

Hi, I have a "large" sql query (like 200 lines)...

dim query as string
query = "..................................." & _
        "..................................." & _
           .... Like a lot lines later...
        "..................................."

function query,"sheet 1"

When i do this, excel says "Too many line continuations."

What is the best way, to avoid this?

Thanks for your help.

A: 

So far I found this...

Call AddToArray(query, "...")
Call AddToArray(query, "...")
... a lot lines later...
Call AddToArray(query, "...")

*edit: Forgot to add:

Sub AddToArray(myArray As Variant, arrayElement As Variant)

If Not IsArrayInitialized(myArray) Then
    ReDim myArray(0)
    myArray(0) = arrayElement
Else
    ReDim Preserve myArray(UBound(myArray) + 1)
    myArray(UBound(myArray)) = arrayElement
End If

End Sub

Source: link text X( thankyou

(Still waiting for better ways to do this...) thankyou :P

pojomx
+2  A: 

There's only one way -- to use less continuations.

This can be done by putting more text on a line or by using concatenation expressed differently:

query = ".........."
query = query & ".........."
query = query & ".........."

But the best is to load the text from an external source, as a whole.

GSerg
A bit dirty but works :)
pojomx
A: 

Split the query into several sections:

query = _
  "............" & _
  "............" & _
  "............"
query = query & _
  "............" & _
  "............" & _
  "............"
query = query & _
  "............" & _
  "............" & _
  "............"
Guffa
This is what i didnt want to do :) thanks
pojomx