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


Hi,

I would like to know how to write a macro that selects all rows/column
on a worksheet and perform the trim function (both right and left
within each cell.

thanks a lot!

--
molavi11
-----------------------------------------------------------------------
molavi111's Profile: http://www.excelforum.com/member.php...fo&userid=1461
View this thread: http://www.excelforum.com/showthread.php?threadid=26244

  #2   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Trim function in VBA

Actually, I think you need Application.Selection.Cells

my bad

"molavi111" wrote:


Hi,

I would like to know how to write a macro that selects all rows/columns
on a worksheet and perform the trim function (both right and left)
within each cell.

thanks a lot!!


--
molavi111
------------------------------------------------------------------------
molavi111's Profile: http://www.excelforum.com/member.php...o&userid=14618
View this thread: http://www.excelforum.com/showthread...hreadid=262446


  #3   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Trim function in VBA

Try this:

Public Sub TrimItAll()

For Each objC In Application.Selection

objC.Value = Trim(objC.Value)

Next

End Sub



"molavi111" wrote:


Hi,

I would like to know how to write a macro that selects all rows/columns
on a worksheet and perform the trim function (both right and left)
within each cell.

thanks a lot!!


--
molavi111
------------------------------------------------------------------------
molavi111's Profile: http://www.excelforum.com/member.php...o&userid=14618
View this thread: http://www.excelforum.com/showthread...hreadid=262446


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trim function in VBA

Sub doATrim()
for each cell in Activesheet.UsedRange.specialCells(xlconstants,
xlTextValues)
cell.Value = trim(cell.Value)
Next
End Sub

--
Regards,
Tom Ogilvy


"molavi111" wrote in message
...

Hi,

I would like to know how to write a macro that selects all rows/columns
on a worksheet and perform the trim function (both right and left)
within each cell.

thanks a lot!!


--
molavi111
------------------------------------------------------------------------
molavi111's Profile:

http://www.excelforum.com/member.php...o&userid=14618
View this thread: http://www.excelforum.com/showthread...hreadid=262446



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 function dannyboy8 Excel Discussion (Misc queries) 1 May 19th 10 03:47 PM
trim function [email protected] Excel Worksheet Functions 3 December 30th 05 03:00 AM
Need help with TRIM function Phil Excel Worksheet Functions 9 October 21st 05 08:02 PM
Trim Function Steved Excel Worksheet Functions 5 August 4th 05 11:06 PM
How to use TRIM function Sky Warren Excel Worksheet Functions 3 January 8th 05 05:06 PM


All times are GMT +1. The time now is 03:23 AM.

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"