Hi,
I am using the following Macro to TRIM text in an Information Sheet. The text must be without leading spaces since formulas in other worksheet would not work properly. This is just a safeguard in case entry is sloppy.
I would like to activate the Macro upon leaving the sheet. I tried "deactivate" but that causes a lengthy calculation. Is there a way to avoid the lengthy calculation? The text that needs to be trimmed is in B6:C22 and B24:G36.
Private Sub Worksheet_Activate()
ActiveSheet.Unprotect
Dim cell As Range
For Each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants)
cell = WorksheetFunction.TRIM(cell)
Next cell
ActiveSheet.Protect
End Sub
Thanks in advance for any help!
Bookmarks