Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Trim Entire Column

Data was imported into a worksheet but the first column has the data padded
with spaces on the right of it. Is there a way to trim the data in the column
in one shot? The only way I know how would be the long way which is create
another column, do a trim on the data of the adjacent column, copy and paste
special as value the new column and then delete the original column.

There must be a better way in VBA.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Trim Entire Column

This is setup for column A
Sub trimData()
Dim rng As Range
Dim Cell As Range
Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
For Each Cell In rng
Cell.Value = Trim(Cell.Value)
Next Cell
End Sub

"Bob Zimski" wrote:

Data was imported into a worksheet but the first column has the data padded
with spaces on the right of it. Is there a way to trim the data in the column
in one shot? The only way I know how would be the long way which is create
another column, do a trim on the data of the adjacent column, copy and paste
special as value the new column and then delete the original column.

There must be a better way in VBA.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Trim Entire Column

Just what the doctor ordered.
Thanks Mike

"Mike" wrote:

This is setup for column A
Sub trimData()
Dim rng As Range
Dim Cell As Range
Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
For Each Cell In rng
Cell.Value = Trim(Cell.Value)
Next Cell
End Sub

"Bob Zimski" wrote:

Data was imported into a worksheet but the first column has the data padded
with spaces on the right of it. Is there a way to trim the data in the column
in one shot? The only way I know how would be the long way which is create
another column, do a trim on the data of the adjacent column, copy and paste
special as value the new column and then delete the original column.

There must be a better way in VBA.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Trim Entire Column

Your welcome.

"Bob Zimski" wrote:

Just what the doctor ordered.
Thanks Mike

"Mike" wrote:

This is setup for column A
Sub trimData()
Dim rng As Range
Dim Cell As Range
Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
For Each Cell In rng
Cell.Value = Trim(Cell.Value)
Next Cell
End Sub

"Bob Zimski" wrote:

Data was imported into a worksheet but the first column has the data padded
with spaces on the right of it. Is there a way to trim the data in the column
in one shot? The only way I know how would be the long way which is create
another column, do a trim on the data of the adjacent column, copy and paste
special as value the new column and then delete the original column.

There must be a better way in VBA.

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trim varying decimals from column of numbers AuthorizedUserPF Excel Worksheet Functions 9 March 30th 10 04:34 PM
Need macro to trim characters in column TonyV Excel Programming 5 January 10th 08 04:51 PM
Trim the entire range Greg Excel Programming 1 November 6th 07 07:36 PM
Trim content of a column BZeyger Excel Programming 14 November 1st 07 06:06 PM
How to apply the trim function to a whole column. Ramki Excel Programming 1 May 5th 06 07:45 AM


All times are GMT +1. The time now is 12:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"