Trim Cells

A

aftamath

How do I perform a trim function on a range of cells using VBA. Ultimately,
I would like to select all cells in a column and perform the trim function.
 
C

Chip Pearson

Try something like the following:

Dim Rng As Range
For Each Rng In Application.Intersect(ActiveCell.EntireColumn, _
ActiveSheet.UsedRange.SpecialCells(xlTextValues)).Cells
Rng.Value = Application.Trim(Rng.Text)
Next Rng


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Top