Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping data after the Trim function is used. 1

Status
Not open for further replies.

Mizzness

Programmer
May 2, 2003
174
US
Hello All.

I am using the macro recorder in XP Pro.
My task is to take the data in column A, use Trim sd replace the data in column A with the "new Trimmed" data.
The steps I have taken are:
Insert a column to the right of column A.
In that column (B) use the Trim function and copy paste it down all the rows (about 1,200) as applicable.
Copy paste/value the "Trimmed" data in column B to column A and delete column B.
The result I keep getting is the first rows data getting copied down only.
Example: rows A3 thru A5 has the following data - 98765 (A3) / 76543 (A4) / 23478 (A5) only 98765 gets copied down the entire field.

I have included my macro for guidance.

Thanks for any and all help.

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 9/29/2003 by AM
'

'
Selection.EntireColumn.Insert
ActiveCell.FormulaR1C1 = "=TRIM(RC[-1])"
Range("B3").Select
Selection.AutoFill Destination:=Range("B3:B1041")
Range("B3:B1041").Select
Calculate
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
ActiveCell.FormulaR1C1 = "c"
Range("A2").Select
End Sub










 
Skip,

Worked like a charm.
A star for helping me in the difficulty of simplicity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top