Line continuation.

D

Dave

Hi,XL2003
I have the following all on one line:

Range("A2") =
"=SUMPRODUCT(--(B$2:B$445=B2)*(C$2:C$445=C2)*(D$2:D$445=D2)*(G$2:G$445=G2)*(H$2:H$445=H2)*(I$2:I$445=I2))"

This line works fine as it is. But if I try to use the <space underscore>
line continuation thingy somewhere in the line, the text turns red, and an
error message comes up: Compile error. Expected end of statement.
Is this normal VBA behaviour, or am I missing something?
 
C

Chip Pearson

You can do something like

S = "=SUMPRODUCT(--(B$2:B$445=B2)*(C$2:C$445=C2)*(D$2:D$445=D2)" & _
"*(G$2:G$445=G2)*(H$2:H$445=H2)*(I$2:I$445=I2))"

Since you are concatenating strings, each string must be enclosed in "
characters. I suspect you didn't have a " before the line continuation
characters.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

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

Top