Dim c As Range
For Each c In Range("A1:AU500")
c = [COLOR="#FF0000"]L[/COLOR]Trim(c.Value)
Next
You need to put the posted code inside a macro housing. If you do not have your own macro to add it to, here is what it would look like as a standalone macro...Thank you JLGWhiz and Mark858. When attempting to run the VBA I receive the following error message: "Compile error: Invalid outside procedure". Any thoughts? Thanks again.
Sub TrimLeadingSpaces()
Dim c As Range
For Each c In Range("A1:AU500")
c = LTrim(c.Value)
Next
End Sub
I think this one macro would handle both situations...Thanks Rick! This works; I thought I was doing this earlier, but must have missed something. Quick question: If I also wanted to trim leading zeros from the same range, would I need a separate macro or could the code be incorporated/ built on the one above? Thanks again for your help.
Sub TrimLeadingZerosAndSpaces()
Dim c As Range
For Each c In Range("A1:AU500")
c = Replace(LTrim(Replace(c.Value, "0", " ")), " ", "0")
Next
End Sub