In this tutorial, you will learn about how to Use Wrap Text in Excel VBA.
What is Wrap Text?
If we have a single cell text length, reach up to multiple cells or columns and we want to adjust this text into a single cell.
Suppose that we have a text data in cell “A1” (See image
below), and this text length reaches up to the next 3 cells or the next 3 columns.
See image below:-
But we want to adjust this whole text data into a single
cell.
Now with the help of Visual Basic, I will adjust the whole text in a single cell by using the “Wrap Text” method in VBA.
Go to the Developer tab and Click Visual Basic
Insert a new module and write the below-given code.
See the first image where our cell data exist in the original format.
In the above image, I have written two lines of code.
This is a simple code of converting our text data as “Wrap
Text” and again convert this text as a normal mode by executing another line of
code.
Now I will execute the code by pressing ‘F8’ function key
for step by step execution.
By executing the first line as “True”, convert our text data
as Wrap Text or adjust our all text data into one cell.
Again pressing “F8” for executing our second line of code, this convert
our “Wrap Text” data into normal text data or in the usual format.
I hope this small tutorial help to understand this method of VBA to Wrap
Text in Excel.
I hope you find this helpful.
Please feel free to put your comments to give me a small
boost.
Regards