#1   Report Post  
aftamath
 
Posts: n/a
Default Trim Cells

How do I perform a trim function on a range of cells using VBA. Ultimately,
I would like to select all cells in a column and perform the trim function.
  #2   Report Post  
Chip Pearson
 
Posts: n/a
Default Trim Cells

Try something like the following:

Dim Rng As Range
For Each Rng In Application.Intersect(ActiveCell.EntireColumn, _
ActiveSheet.UsedRange.SpecialCells(xlTextValues)). Cells
Rng.Value = Application.Trim(Rng.Text)
Next Rng


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"aftamath" wrote in message
...
How do I perform a trim function on a range of cells using VBA.
Ultimately,
I would like to select all cells in a column and perform the
trim function.



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
how do you "select locked cells" w/o "select unlocked cells"? princejohnpaulfin Excel Discussion (Misc queries) 3 July 16th 05 03:53 AM
Deselect Cells while using ctrl Sloth Excel Discussion (Misc queries) 5 July 14th 05 10:58 PM
Counting only active cells Sac73 Excel Discussion (Misc queries) 16 April 4th 05 05:49 AM
Help adding text values Texas-DC_271 Excel Worksheet Functions 7 January 15th 05 11:14 PM
Convert data type of cells to Text,Number,Date and Time Kevin Excel Worksheet Functions 1 December 31st 04 12:57 PM


All times are GMT +1. The time now is 05:13 PM.

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

About Us

"It's about Microsoft Excel"