How to separate on very long line of code in VBA
On Nov 5, 7:50*am, "Clif McIrvin" wrote:
"Clif McIrvin" wrote in message
...
"Andrew" wrote in message
....
Hello,
I'm trying to figure out how to put a single command onto several
lines. *This is necessary when the line of code is much wider than
the
editing screen. *I see in examples that people use _ to separate
lines
of code. *When I try this my code turns red and VBA tells me I have
an
error. *Can someone please explain how this is done.
thanks,
Andy
you need a space before the _
from the VBA help glossary:
<quote
line-continuation character
The combination of a space followed by an underscore ( _) used in the
development environment to extend a single logical line of code to two
or more physical lines. However, you can't use a line-continuation
character to continue a line of code within a string expression.</quote
If the preceeding space wasn't you problem, did you enter a <cr after
the underscore?
From the VBE window, press F1 for help and search for line continuation
for more information.
--
Clif McIrvin
(clare reads his mail with moe, nomail finds the bit bucket :-)
Thanks for the tip. I was trying to break a string. That explains
it.
|