Hi XLnt team!
I have made some VBA code to trim the selected cells. But it trims only spaces before and after text, not multiple spaces between text characters (i.e "te x t").
Can someone tell me how to edit my code to work as the TRIM formula does?
VBA code:
Sub TrimSelection()
Dim cell As Range
For Each cell In Selection
If Not cell.HasFormula Then
cell.Value = Trim(cell.Value)
End If
Next cell
End Sub
Thanks!
I have made some VBA code to trim the selected cells. But it trims only spaces before and after text, not multiple spaces between text characters (i.e "te x t").
Can someone tell me how to edit my code to work as the TRIM formula does?
VBA code:
Sub TrimSelection()
Dim cell As Range
For Each cell In Selection
If Not cell.HasFormula Then
cell.Value = Trim(cell.Value)
End If
Next cell
End Sub
Thanks!