Line continuation

D

Dave

Hi,
XL2003
I cannot use the < space Underscore > line continuation on the following
line without generating an error.

Range("A1") =
"=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))"

The line works ok in its current state. What am I doing wrong?
Regards - Dave.
 
O

OssieMac

Hi Dave,

You can't insert a line break in a string enclosed in double quotes. You
have to close off the double quotes, insert an ampersand (&) then space and
underscore and then on the next line open the double quotes again.

In other words, break the string up into smaller strings and concatenate
them with the ampersand and then place the linebreak either before or after
the ampersand.

Range("A1") = "=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))"
 
D

Dave

OK, thanks. Didn't know there were rules for using the line break in VBA.
Sorry about the repeated posts. As you say, a problem with the site.
Dave.
 

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