Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Find End in Undefined Range > Select Range > Trim

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SteveT - 29 Nov 2007 18:01 GMT
Hello,

I'm working with .CSV worksheet that arrives already 'Text to Colmuns....'
The data is delimited resulting in various data positioning.

Can someone help with macro that will
1) Find 'END CELL' In sheet given random placement of data
2) Select Range.A1: 'END CELL'
3) Trim all cells within the Range

I've searched through the posted solutions on the subject and tried various
combinations of posts but having no luck

Many thanks / Happy Holidays
Steven
Bernie Deitrick - 29 Nov 2007 18:13 GMT
Steve,

Sub TryNow()
Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeConstants)
  myC.Value = Application.Trim(myC.Value)
Next myC
End Sub

HTH,
Bernie
MS Excel MVP

> Hello,
>
[quoted text clipped - 11 lines]
> Many thanks / Happy Holidays
> Steven
Gary''s Student - 29 Nov 2007 18:18 GMT
First extend activesheet.usedrange back to A1 (may not be necessary):

Sub trimum()
Set rr = Range(Range("A1"), ActiveSheet.UsedRange)
For Each r In rr
   r.Value = Trim(r.Value)
Next
End Sub

If your "random placement of data" is not activesheet.usedrange, then update
the second statement accordingly.
Signature

Gary''s Student - gsnu200759

> Hello,
>
[quoted text clipped - 11 lines]
> Many thanks / Happy Holidays
> Steven
Michael - 29 Nov 2007 18:20 GMT
Sub Findntrim()
LastCell = Range("A65536").End(xlUp).Row

For i = 1 To LastCell
   Cells(1, i).Value = Trim(Cells(1, i))
Next i
End Sub
Signature

If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.

> Hello,
>
[quoted text clipped - 11 lines]
> Many thanks / Happy Holidays
> Steven
SteveT - 29 Nov 2007 18:54 GMT
Bernie / Student of Gary / Michael

Thank You All for the quick responses!

Bernie, Your solution worked instantly - perfect
Student of Gary, Your's took nano second longer :) - Thanks
Michael, No Luck Sir :)

Again - Thanks !

> Hello,
>
[quoted text clipped - 11 lines]
> Many thanks / Happy Holidays
> Steven
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.