The 1-Formula Fix for Excel’s Messiest Tables @LeilaGharani
The 1-Formula Fix for Excel’s Messiest Tables  @LeilaGharani
Uploaded September 2026 | Updated September 2026, 12 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 Tables🐠 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 #shortsWindows 11 Introduces Game Changing Feature (which will probably convince many to upgrade)Google Maps Hidden Tip: How to forecast traffic ahead of time #shortsπŸ†• How to Use WRAPROWS & WRAPCOLS Function in Excel #shortsSay Goodbye to Boring Excel Tasks: Create Cool Buttons to Run Office Scripts from ANYWHEREIts not the sound of your voice.My Studio Tour 2022! Where we film & tools we use
Leila Gharani |

The 1-Formula Fix for Excel’s Messiest Tables

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER