Trimming an entire Column of text

C

CG

Richard Scholler posted this solution on Ozgrid:

Sub TrimCol()
Dim r As Range
Set r = Intersect(ActiveCell.EntireColumn,
ActiveSheet.UsedRange)
r.Value = Evaluate("IF(ROW(" & r.Address & "),IF(" & r.Address &
"<>"""",TRIM(" & r.Address & "),""""))")
End Sub

I just get a #NUM! when I use this. Does anyone know why? This
solution using Evaluate is in several places on the web.

http://www.ozgrid.com/forum/showthread.php?t=77535
 
H

Héctor Miguel

hi, !
Richard Scholler posted this solution on Ozgrid:

Sub TrimCol()
Dim r As Range
Set r = Intersect(ActiveCell.EntireColumn, ActiveSheet.UsedRange)
r.Value = Evaluate("IF(ROW(" & r.Address & "),IF(" & r.Address & "<>"""",TRIM(" & r.Address & "),""""))")
End Sub

I just get a #NUM! when I use this. Does anyone know why?
This solution using Evaluate is in several places on the web...

try this way...

Sub TrimCol()
With Intersect(ActiveCell.EntireColumn, ActiveSheet.UsedRange)
.Value = Evaluate("transpose(transpose(trim(" & .Address & ")))")
End With
End Sub

hth,
hector.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top