DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

How to Remove Text Wrap Using Macros (VBA) in Excel Office 365?

Remove Text Wrap Using Macros:

In this article, we are going to explore how to Remove Text Wrap Using Macros in Excel Office 365 with an example. Get an official version of MS Excel from the following link: https://www.microsoft.com/en-in/microsoft-365/excel

Remove Text Wrap Using Macros:

To remove text wrap using Macros in the Excel spreadsheet, do as follows.

  • On the Developer Tab, select the Visual Basic option under the Code section.

Select Visual Basic option
Select Visual Basic option

  • You have to activate the sheet where you want to remove text wrap in Excel.
  • Now, enter the below code.

VBA code for removing text wrap in Excel

Sub RemoveWrapAndAutofitCells()

Activate

Cells.Select

‘Remove the Text Wrap

Selection.WrapText = False

‘Autofit all of the cells afterwards

Cells.EntireRow.AutoFit

Cells.EntireColumn.AutoFit

End Sub

  • You need to save the code by selecting it. Then close the window.

Enter the source code
Enter the source code

  • You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.

Select the Macros option
Select the Macros option

  • You have to make sure that your macro is selected and click the Run button.

Macro dialog box
Macro dialog box

Before applying the VBA & Macros Code:

Example data
Example data

After running the VBA & Macros Code:

  • Now, you can get the output as shown in the below image.

Result
Result

Verdict:

In the above article, you can learn the steps to Remove Text Wrap Using Macros in Excel Office 365 with an example. Leave your feedback in the comment section. Thanks for visiting Geek Excel. Keep Learning!!

Top comments (0)