New Line or Carriage Return in Excel VBA

In this post, you’ll learn about the usage of vbNewLine, vbCrLf or vbCR to insert line break in your Excel spreadsheet using Excel VBA.

vbNewLine in Excel VBA

Below is a code snippet demonstrating how you can use vbNewLine to insert new line after the first string.

Sub InsertNewLinevbNewLine()

Dim str1 As String
Dim str2 As String

str1 = "String 1"
str2 = "String 2"

Debug.Print str1 & vbNewLine & str2

End Sub

vbCrLf in Excel VBA

The below code snippet show how you can insert new line using vbCrLf using Excel VBA.

Sub InsertNewLinevbCrLf()

Dim str1 As String
Dim str2 As String

str1 = "String 1"
str2 = "String 2"

Debug.Print str1 & vbCrLf & str2

End Sub

vbCR in Excel VBA

The below code snippet demonstrates how you can use vbCR to insert new line using Excel VBA.

Sub InsertNewLinevbCr()

Dim str1 As String
Dim str2 As String

str1 = "String 1"
str2 = "String 2"

Debug.Print str1 & vbCr & str2

End Sub
New Line or Carriage Return in Excel VBA

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn how to Find Blank cells in excel so that you can remove or delete the blank cells form...
In this article, you’ll learn what is a Gauge Chart in Microsoft Excel. Also, you will learn how to add...
Microsoft Excel provides a shortcut for the users to move columns in excel using two different ways – using Shift...