1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel Macro - Code Continuation

Discussion in 'Business Applications' started by CWDENVER, Feb 9, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. CWDENVER

    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.
     
  2. OBP

    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?
     
  3. CWDENVER

    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?
     
  4. bomb #21

    bomb #21

    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
     
  5. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Post your code. ;)
     
  6. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/542672

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice