Pinterest Pixel

How to Remove Text Wrap Using Macros in Excel

Bryan
One of the recurring challenges is dealing with removing text wrap.
Instead of manually turning off Wrap Text for multiple cells, rows, or entire worksheets, you can use VBA macros to remove Wrap Text quickly.

In this article, you will learn how to remove text wrap using macros in Excel.

One of the recurring challenges is dealing with removing text wrap. Instead of manually turning off Wrap Text for multiple cells, rows, or entire worksheets, you can use VBA macros to remove Wrap Text quickly. In this article, you will learn how to remove text wrap using macros in Excel.

Key Takeaways:

  • Wrap Text displays long cell content on multiple lines within the same cell.
  • Macros allow you to remove text wrap from cells.
  • You can customize the macro to work on selected cells or the entire worksheet.
  • Save the macro in .xlsm format to preserve the VBA code.
  • Keep backups to prevent accidental data loss or overwriting.

 

Download excel workbookHow-to-Remove-Text-Wrap.xlsm

 

Understand Wrap Text in Excel

Wrap text in Excel is a formatting feature that allows you to display long cell content on multiple lines in the same cell. When text wrap is enabled, Excel automatically adjusts the row height to accommodate all the lines. This can cause your rows to become uneven and harder to navigate.

There may be certain situations where you may want to remove wrap text:

  • Standardize worksheet formatting.
  • Improve worksheet readability.
  • Reduce row height.
  • Prepare data for printing or exporting.
  • Remove unwanted text wrapping from imported data.

 

How to Wrap Text using Macros in Excel

Enable the Developer Tab

STEP 1: Open Excel and click on the File menu.

How to Wrap Text using Macros in Excel

STEP 2: Select Options at the bottom of the menu.

How to Wrap Text using Macros in Excel

STEP 3: In the Excel Options window, choose Customize Ribbon from the left pane. On the right side, find the list of main tabs, then check the box for Developer. Click OK.

How to Wrap Text using Macros in Excel

The Developer tab should now appear in your Excel ribbon.

How to Wrap Text using Macros in Excel

Use a VBA Code to Remove Text Wrap

STEP 1: Go to Developer > Code > Visual Basic

Insert Macro

STEP 2: Paste in your code and Select Save. Close the window afterwards.

How to Remove Text Wrap Using Macros in Excel

STEP 3: Let us test it out!

Open the sheet containing the data. Go to Developer > Code > Macros

How to Remove Text Wrap Using Macros in Excel

Make sure your macro is selected. Click Run.

How to Remove Text Wrap Using Macros in Excel

With just one click, all of the cells now have text wrap removed!

How to Remove Text Wrap Using Macros in Excel

 

Save and Run My Macro

Save the Macro-Enabled Workbook

After writing or editing my macro, I always save my file as a macro-enabled workbook (.xlsm).

How to Wrap Text using Macros in Excel

This ensures my VBA code is preserved and ready for future use. Saving it in the right format is important – regular .xlsx files will remove all your VBA work. I also name the file clearly so I can easily distinguish it from other versions.

Run the Macro

  • Open the Developer tab, and click Macros
  • I pick the macro I want
  • Press Run

How to Wrap Text using Macros in Excel

Tips & Tricks

  • Save a backup copy of your workbook before running any macro.
  • Test the macro on a small sample of data before applying it to large worksheets.
  • Save your workbook in the .xlsm format to preserve the VBA code.
  • Verify that the correct worksheet or range is selected before running the macro.
  • Assign the macro to a button or keyboard shortcut if you use it frequently.
  • Keep your VBA code organized and add comments for easier maintenance.
  • Avoid downloading macros from untrusted sources to protect your files and data.

FAQs

What is Wrap Text in Excel?

Wrap text is a formatting feature in Excel that allows you to fit long text in multiple lines in the same cell.

What is the format in which Excel files with macros are saved?

Microsoft Excel files containing VBA macros are saved in .XLSM format.

Does removing text wrap delete any data?

No, when you remove wrap text in Excel, it does not delete any data.

How to remove text wrap from selected cells?

You can modify the VBA code to work only on the cells you select.

Can I undo a macro after running it?

Usually, Excel does not allow you to use the Undo feature after a macro runs. It is recommended to save a backup copy of your workbook before executing a macro.

If you like this Excel tip, please share it




Bryan

Bryan Hong is an IT Software Developer for more than 10 years and has the following certifications: Microsoft Certified Professional Developer (MCPD): Web Developer, Microsoft Certified Technology Specialist (MCTS): Windows Applications, Microsoft Certified Systems Engineer (MCSE) and Microsoft Certified Systems Administrator (MCSA).

He is also an Amazon #1 bestselling author of 4 Microsoft Excel books and a teacher of Microsoft Excel & Office at the MyExecelOnline Academy Online Course.

See also  How to Insert Numbers Using Macros in Excel

Star 30 Days - Full Access Star

One Dollar Trial

$1 Trial for 30 days!

Access for $1

Cancel Anytime

One Dollar Trial
  • Get FULL ACCESS to all our Excel & Office courses, bonuses, and support for just USD $1 today! Enjoy 30 days of learning and expert help.
  • You can CANCEL ANYTIME — no strings attached! Even if it’s on day 29, you won’t be charged again.
  • You'll get to keep all our downloadable Excel E-Books, Workbooks, Templates, and Cheat Sheets - yours to enjoy FOREVER!
  • Practice Workbooks
  • Certificates of Completion
  • 5 Amazing Bonuses
Satisfaction Guaranteed
Accepted paymend methods
Secure checkout

Get Video Training

Advance your Microsoft Excel & Office Skills with the MyExcelOnline Academy!

Dramatically Reduce Repetition, Stress, and Overtime!
Exponentially Increase Your Chances of a Promotion, Pay Raise or New Job!

Learn in as little as 5 minutes a day or on your schedule.

Learn More!

Share to...