Sub TrimTrailingWS DIM cell AS OBJECT DIM cells AS OBJECT DIM sheet AS OBJECT DIM row, col AS INTEGER DIM msgtext AS STRING cells = ThisComponent.CurrentSelection.RangeAddress sheet = ThisComponent.CurrentController.ActiveSheet For col = cells.StartColumn To cells.EndColumn For row = cells.StartRow To cells.EndRow cell = sheet.getCellByPosition(col,row) If Len(cell.String) > Len(Trim(cell.String)) Then cell.String = Trim(cell.String) End If Next Next msgtext = ">> Checked for (" + cells.StartRow + "," + cells.StartColumn + ")" msgtext = msgtext + " - (" + cells.EndRow + "," + cells.EndColumn + ")" Msgbox msgtext End Sub