This project fixes Excel sheets where some cells contain more than one line because someone used ALT+ENTER. Those stacked lines create issues when the data needs to be filtered or processed.
The tool turns every line into its own row and keeps the main columns aligned.
- Looks for cells that have multiple lines inside them
- Splits each line into a new row
- Keeps P&ID, Line Number, and other fixed columns in place
- Matches the structure shown in your “correct” example where repeated values stay merged or consistent across the new rows
I had a sheet where one row held several instrument tags in the same cell, and it made sorting and checking the data messy. Splitting everything by hand would take too long.
This script automates the whole thing.
- Open your Excel file
- Run the script (VBA or Python version, depending on what this repo contains)
- The tool checks the target columns
- Every line break becomes a new row
- The rest of the row is copied so the data stays aligned
- Open Excel
- Press
ALT + F11 - Insert a new module
- Paste the code from this repo
- Run the macro on your sheet
-
Install
openpyxl -
Place your Excel file in the same folder
-
Run
python split_rows.py -
The script creates a cleaned file with the updated rows
- Script file (VBA or Python)
- Sample Excel (optional)
- README