Sub MyTrim()
Dim lc As Long
Dim c As Long
Application.ScreenUpdating = False
' Find last column with data in row 1
lc = Cells(1, Columns.Count).End(xlToLeft).Column
' Loop through all columns
For c = 1 To lc
' Trim values
Cells(1, c) = Trim(Cells(1, c))
Next c
Application.ScreenUpdating = True
End Sub