VBA Wrap Text

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on July 19, 2021

In this tutorial, you will learn about how to enable or disable Wrap Text in Excel using VBA.

Wrapping Text using VBA

You wrap the text in a cell or range by setting the Range.WrapText Property of the Range object to True. The following code will wrap the text in cell A1:

Worksheets("Sheet1").Range("A1").WrapText = True

The result is:

Wrapping Text in VBA

You can Wrap a larger range of cells as well:

Range("A1:A10").WrapText = True

 

Disabling Wrapping in a Cell using VBA

You can disable text wrapping in a certain cell or range using VBA. The following code will disable text wrapping in cell B2:

Range("B2").WrapText = False

Disabling Wrapping in An Entire Worksheet

You can disable text wrapping in all the cells on a worksheet using VBA. The following code will allow you to disable text wrapping in all the cells in the ActiveSheet:

Sub DisableWrapText ()

    Cells.WrapText = False

End Sub

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!
vba-free-addin

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples