Excel Macro - Code Continuation

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

CWDENVER

Thread Starter
Joined
Dec 1, 2006
Messages
38
I've actually written a line of code that is too long to fit in the macro window. How can I continue the code on another line in the programming window? I've tried using &'s but it doesn't work. Thanks.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
The correct method is the "_" character, you will see recorded macros and help examples with that character splitting up the line in to approximately 50 - 80 characters so that it all fits the screen
It goes at the end of each line.
Does it all have to be on one line anyway?
 

CWDENVER

Thread Starter
Joined
Dec 1, 2006
Messages
38
No it doesn't have to be on the second line, but I'm creating a MsgBox that has a lot of words/spreadsheet values in it. Does the _ have to be at the end of the first line AND the beginning of the second line? Is there a particular place I should put it? Also, every time I try to use this, the Excel file locks up and I can't do anything but close it out. What am I doing wrong?
 
Joined
Jul 1, 2005
Messages
8,546
At the end of the line only, but the underscore must be preceded by a space. For example:

Sub test()
MsgBox "I've actually written a line of code that is too long to fit " & _
"in the macro window. How can I continue the code on another line in " & _
"the programming window? I've tried using &'s but it doesn't work. Thanks."
End Sub
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top