H
Hector Fernandez
I am trying to perform a single event to multiple ranges but for some
reason I can't get the macro to work if I write it on multiple lines.
If, for example, I write:
Sub Clear_Ranges()
Range("range1,range2,range3") = clear
End Sub
The macro works just fine and clears the ranges. However, if I do the
following:
Sub Clear_Ranges()
Range("range1, _
range2, _
range3") = clear
End Sub
I get an error message "Compile Error: Expected: List separator or )"
I thought that using a space and underscore was suppose to allow you to
write a single line of code across several lines in order to make it
easier to read or fit in a page.
I intend to have a lot more than three ranges in the macro and it will
be very messy and long if I try to put it on a single line.
What am I doing wrong?
Is there an easier way to perform the same thing on several different
ranges?
Thanks.
reason I can't get the macro to work if I write it on multiple lines.
If, for example, I write:
Sub Clear_Ranges()
Range("range1,range2,range3") = clear
End Sub
The macro works just fine and clears the ranges. However, if I do the
following:
Sub Clear_Ranges()
Range("range1, _
range2, _
range3") = clear
End Sub
I get an error message "Compile Error: Expected: List separator or )"
I thought that using a space and underscore was suppose to allow you to
write a single line of code across several lines in order to make it
easier to read or fit in a page.
I intend to have a lot more than three ranges in the macro and it will
be very messy and long if I try to put it on a single line.
What am I doing wrong?
Is there an easier way to perform the same thing on several different
ranges?
Thanks.