excel vba how to continue on next line

'VBA uses the combination of a Space character AND an Underscore to 
'continue a line of code to the next line.

'For example:

MyVariable = ThisWorkbook.Worksheets("Sheet1").Range("A1").Value & _
             ThisWorkbook.Worksheets("Sheet2").Range("A1").Value
     
     
'------------------------------------------------------------------
'Caveat 1: The line break is not allowed 
'          in the middle of quoted literal text.

'Caveat 2: The line break can only happen where a Space character
'          would be allowed. For example, you are not allowed to
'          split up dot notation for an object's scope and
'          properties and methods.

'Caveat 3: One line of code can have a maximum of 24 line breaks.

'Caveat 4: One line of code can have a max of 1024 characters,
'          whether it is continued or not.

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source