2 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

How do you handle messy data with inconsistent spaces across hundreds of columns?

Our take

Handling messy data, especially with inconsistent leading spaces across hundreds of columns, can be daunting. In scenarios like this, Power Query emerges as a powerful ally, allowing you to efficiently trim spaces from multiple columns simultaneously, thus saving valuable time. While leveraging Power Query for this task can streamline the process, it’s wise to consider potential performance implications when working with extensive data sets. Exploring VBA solutions can also provide tailored automation for repeated tasks.

I just got handed a spreadsheet with over 300 columns and the data is a complete mess. Every single entry has a leading space before the actual text. Not trailing spaces just a space at the start of each cell. Someone apparently copy pasted from somewhere without trimming and now I have to clean this up for a report due Friday.

I know about the TRIM function but manually applying it to 300 columns one by one is going to take forever. I tried using find and replace with a space and replace with nothing but that also removes spaces between words which I need to keep. So thats not going to work.

Power Query seems like the obvious answer here but Im curious how others would approach this. If I load the whole table into Power Query I can select all columns and do a trim transform in one go which feels way faster. But I rarely work with this many columns and Im wondering if theres any performance downside or gotchas I should watch out for.

Also open to VBA solutions if anyone has a macro for this. Just trying to figure out the most efficient way before I commit to a method. Curious how the pros handle massive cleanup jobs like this.

submitted by /u/paintarose
[link] [comments]

Read on the original site

Open the publisher's page for the full experience

View original article

Related Articles