Trim function in a macro
will this work for you?
Sub mac1()
Dim lastrow As Long
Dim cell As Range
Dim rng As Range
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A1:A" & lastrow)
For Each cell In rng.Cells
cell.Offset(0, 1).Value = Trim(cell)
Next cell
End Sub
--
Gary
"Domingos Junqueira" wrote in message
...
Hi,
I would like to use a trim function to delete spaces before and after a
text in an entire column, but so far I could only use it in a cell:
Sub mac1()
Dim testing As String
testing = ActiveSheet.Range("A1")
ActiveSheet.Range("B1") = Trim(testing)
End Sub
Thanks for any help,
--
Domingos Junqueira
|