Tuesday, March 30, 2010

How to clean the leading or trailing cell spaces in a given range

Using this function you can now clean the leading or trailing spaces in the cell range

Function Clean_cells_in_range(ByRef Cells_to_Clean As String)

    For Each cell In ActiveSheet.Cells.Range(Cells_to_Clean)
        cell.Value = Trim(cell)
    Next cell

End Function

No comments:

Post a Comment