VBA & Macro Problems

Excel VBA: Autofit Rows After Multiple Drop-Down Selections

Steven ParkerSteven Parker Nov 22, 2026 868 views

Question details

Adjust an Excel Worksheet_Change macro so combined data validation selections wrap and the affected row fits the text.

Autofit Excel Rows After Multiple Drop-Down Selections with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet macro combines multiple selections from a data validation drop-down in one cell.
Observed behavior
The combined text does not display correctly within the row.
Before you start

Locate the existing Worksheet_Change procedure for the worksheet and identify where it assigns the combined selection to the changed cell. Confirm that the target cells are not merged, because Excel AutoFit does not reliably adjust row height for merged cells.

Solution 1Recommended

Wrap the combined value and autofit the changed row

Use this fix in the existing multi-selection macro after it assigns the combined value to the cell.

Keep the existing code that combines drop-down selections; data validation alone does not provide multiple selections. Add the row-height commands to the same Worksheet_Change procedure rather than creating a second procedure with that name.

1
Open the worksheet event code

In Excel, open Developer > Visual Basic. In the project pane, double-click the worksheet that contains the drop-down and find its Worksheet_Change procedure.

2
Protect the value update

Before the macro changes the cell value, add `On Error GoTo CleanUp` and `Application.EnableEvents = False`. If the procedure already has an error handler or cleanup label, adapt that handler instead of adding a duplicate.

3
Wrap and fit the row

Immediately after the existing assignment of the combined value, add: Target.WrapText = True Target.EntireRow.AutoFit Keep these lines within the part of the macro that handles the intended drop-down cell.

4
Restore events

Before `End Sub`, add a cleanup section so events are restored even if an error occurs: CleanUp: Application.EnableEvents = True If the procedure already has a cleanup section, add the event-restoration line there instead.

5
Test the drop-down

Return to the worksheet and select several items from the data validation drop-down. Check that the combined text wraps and that the row height expands.

Wrap the combined value and autofit the changed row
Check merged cells: Excel may not autofit the height of rows containing merged cells. Unmerge the affected cells or set the row height manually using Home > Format > Row Height.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and editing Excel files. Its format compatibility makes moving everyday spreadsheet work straightforward, but it does not repair an Excel VBA event macro, and macro compatibility can vary.

Wrap cell text and adjust row height in WPS SpreadsheetOpen and edit Microsoft Excel XLSX filesUse a familiar interface for everyday spreadsheet workMove compatible documents between WPS Office and Microsoft Office
microsoft office alternative - wps office

Frequently Asked Questions

Where should I put the AutoFit command?

In the worksheet's existing Worksheet_Change procedure, place `Target.WrapText = True` and `Target.EntireRow.AutoFit` immediately after the macro assigns the combined selection to the cell.

Why should the macro disable events?

Writing a combined value to the cell can trigger Worksheet_Change again. Set `Application.EnableEvents = False` before the write, then restore it to `True` in the procedure's cleanup section.

Why does AutoFit still not change the row height?

Merged cells can prevent Excel from automatically fitting row height. Unmerge the affected cells or use Home > Format > Row Height to set the height manually.

Does Excel data validation allow multiple selections by itself?

A standard data validation drop-down selects one value at a time. Keep the existing VBA logic that combines selections, and add the wrap and AutoFit commands after its combined-value assignment.

What if worksheet events stop working after I test the macro?

In the Visual Basic Editor, open View > Immediate Window, enter `Application.EnableEvents = True`, and press Enter. Then check that the macro restores events in its cleanup section.