Here is something realy quick. It is ok if it is a one or two time thing but if the size of your data varies and you do it a lot you might want to get the macro to define the rows and columns itself. Let me know if you need more.
Sub trimspaces()
numcol = 100
numRows = 100
For col = 1 To numcol
For Row = 1 To numRows
Cells(Row, col) = trim(Cells(Row, col))
Next Row
Next col
End Sub
David,
I tried your suggestion; unfortunately, it does not work. To see for yourself, type " 03/03/2000 " in cell A1 (make sure to include the spaces . . .of course omitting the quotes).
If I type that particular string inside the trim function it works. . .like this:
Cells(Row, col) = Trim(" 03/03/2000 ").
How can I save the contents of the current cell as a string variable and then use that value inside the trim function?
Thanks in advance.
I tried your suggestion; unfortunately, it does not work. To see for yourself, type " 03/03/2000 " in cell A1 (make sure to include the spaces . . .of course omitting the quotes). If I type that particular string inside the trim function it works. . .like this:
I have found that the DATEVALUE worksheet
function does an excellent job of turning
date-formatted text into date values. It
assumes that the text is in the default date
format (and will use the current year if the
year is omitted). For some reason, however, it
generates a #VALUE! error when confronted with
an actual date.
It should prove useful here because it ignores
any and all extraneous spaces from the
relevant text. See the online help for
more details.
HTH
We have a similar problem daily when we import in
to a worksheet from our business system. Our fix
was to do a find and replace for the entire sheet
(just for formatting reasons). We find all "space"
"space" ( ) and replace with "blank" ()and then
on the critical formula data, we select just the
column with that info and do a find and replace
single "space" and replace with "blank". Takes
just a second to do. Maybe you already tried it,
but it works for us.