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 article, you will learn about the SKEW.P function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the SKEW function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the RANK.EQ function, the formula syntax and usage of the function in Microsoft...
  • Excel
  • November 23, 2021