The 1-Formula Fix for Excel’s Messiest Tables @LeilaGharani
The 1-Formula Fix for Excel’s Messiest Tables  @LeilaGharani
Uploaded September 2026 | Updated December 2026, 3 hours ago
Learn Python in Excel: xelplus.com/course/python-in-excel

Sales data split across monthly columns? Here's how to reshape it into one clean table, with month, sales, and units each in their own column, using Python inside Excel.

=PY
pd.wide_to_long(sales_data, stubnames=["sales","units"], i="sales rep", j="month", sep="_", suffix=".+").reset_index()

- Type =PY and press Tab to activate Python mode
- wide_to_long turns repeated column groups (like sales_Jan, units_Jan) into rows
- stubnames lists the values you're tracking
- i is your identifier column, like sales rep
- j names the new column that holds the month
- sep matches the separator in your source headers
- suffix=".+" means the leftover text can be anything
- reset_index() keeps everything aligned
- Right-click the Python output and choose "Excel Value" to drop it into cells

Add a new month to your source data and the table updates on its own.

Uses the pandas wide_to_long function. Check the pandas docs for the full reference.

πŸ“¨ Subscribe to "Between the Sheets" newsletter to stay on top of office tips and Excel hacks: link.xelplus.com/yt-d-newsletter

πŸ”“ Join this channel to get access to perks:
youtube.com/channel/UCJtUOos_MwJa_Ewii-R3cJA/join

πŸ“² Let’s connect on social:
Instagram: instagram.com/lgharani
LinkedIn: linkedin.com/in/leilagharani

#Excel
The 1-Formula Fix for Excel’s Messiest TablesThe Most Dangerous Excel User🐠 Power BI Aquarium - A Cool Visual to Add to Your Reports #shortsHow to Make Money with Excel SkillsStop Copying & Pasting Like This! πŸ›‘BEST Pivot Table Hacks Youre Not Using #Excel40 #ExcelCopy Text From Videos or Images - Power Toys utility #shortsFile Explorer Tabs in Windows 11: Shortcuts and Hidden TipsπŸ†• How to Use WRAPROWS & WRAPCOLS Function in Excel #shortsIts not the sound of your voice.Dont Type the Dot! | How to Get Power Query Intellisense To Work #shortsChoose Certain Columns as Output in Excel | CHOOSECOLS & FILTER Combo
Leila Gharani |

The 1-Formula Fix for Excel’s Messiest Tables

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER