Excel VBA Macro to TRIM Selection – Episode 2268

Kristin wants to have a fast way to remove leading a trailing spaces from an entire range of Excel cells. In this episode, a 7-line macro to solve this problem.
Sub TrimSelection()
Dim cell As Range
For Each cell In Selection
If Not cell.HasFormula Then
cell.Value = Trim(cell.Value)
End If
Next cell
End Sub

View on YouTube

Further Help

I offer limited consulting services to potentially assist you with data challenges, whether it's designing a complex Excel formula, writing a macro or building a whole new process for data capture, modeling and analysis.  Contact me if you have a need.