Summary

To dynamically transpose a table that contains blanks, you can use an array formula based on the TRANSPOSE function and IF function. In the example shown, the multi-cell array formula in H5:I9 is:

{=TRANSPOSE(IF(B5:F6="","",B5:F6))}

Note: this is an array formula that must be entered with Control + Shift + Enter across the entire range H5:I9, except in Excel 365.

Generic formula

{=TRANSPOSE(IF(rng="","",rng))}

Explanation

The TRANSPOSE function automatically transposes values in a horizontal orientation to vertical orientation and vice versa.

However, if a source cell is blank (empty) TRANSPOSE will output a zero. To fix that problem, this formula contains an IF function that checks first to see if a cell is blank or not. When a cell is blank, the IF function supplies an empty string ("") to transpose. If not, IF supplies the value normally.

Without IF, the array going into TRANSPOSE looks like this:

{"Item","apples","pears","limes",0;"Qty",14,10,4,0}

After IF, it looks like this:

{"Item","apples","pears","limes","";"Qty",14,10,4,""}

Support Exceljet

Many websites (including Exceljet) have lost over half their traffic in the past year because of the crushing impact of AI on web searches. Exceljet is still at it, publishing free content each week. If you find Exceljet helpful, you can support the site and go ad-free with the Exceljet Lifetime Pass. One payment, no subscription, and ads are gone forever. Plus, you get our Excel Shortcuts video course as a thank you.

Get the Lifetime Pass

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.