Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Trim varying decimals from column of numbers | Excel Worksheet Functions | |||
Need macro to trim characters in column | Excel Programming | |||
Trim the entire range | Excel Programming | |||
Trim content of a column | Excel Programming | |||
How to apply the trim function to a whole column. | Excel Programming |