Jun 08 2022 03:07 PM
Is there a macro I could run that would check all selected cells and if some of them have a space at the beginning of them, it would delete that space leaving just the rest of the content?
For example, a selected cell starts as:
testing
(and then corrected to)
testing
Jun 08 2022 03:25 PM
Here you go.
Sub RemoveLeadingSpaces()
Dim cel As Range
Dim rng As Range
Application.ScreenUpdating = False
Set rng = Selection
With rng
Set cel = .Find(What:=" *", LookIn:=xlValues, LookAt:=xlWhole)
If Not cel Is Nothing Then
Do
cel.Value = LTrim(cel.Value)
Set cel = .FindNext(After:=cel)
Loop Until cel Is Nothing
End If
End With
Application.ScreenUpdating = True
End Sub
Jun 08 2022 03:47 PM
A worksheet function that will produce a clean copy of the data is
= TRIM(list)
VBA or TypeScript is needed to alter the original.
Jun 10 2022 08:50 AM