Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2010, 04:11 PM
Registered User
 
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default line breaks & trimming

I'd like to insert a line break into or replace a certain amount of spaces. I've tried using find & replace and did a couple searches that referenced char(10) as line break but it didn't work. I also tried finding char(9) for tabs but I doubt they make it through excels text import process.

q.1.
I need a macro for replacing for every 10 blank spaces and put a line break in the cells of a whole column or selection in excel?


---====---=-=-=-=-=-=-=----AND


I found this vba for removing spaces in a cell
Public Sub RemoveSpaces()
Application.ActiveCell = Trim(Application.ActiveCell)
End Sub

q.2.
How can I make it trim for a whole column or selection?
[FONT=verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif]

Yes I am new to all this and fiddled a bit to actually get the vb editor up, I appreciate the help.[/font]
 
Old April 29th, 2010, 10:02 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

If you want to iterate the ranges

Public Sub RemoveSpaces_Loop()

For Each oCell in Range("A1:B5").cells
oCell .Value = Trim(oCell .Value)
Next oCell
End Sub

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
line breaks mister_mister XSLT 14 March 17th, 2008 12:55 PM
Line Breaks in Access? chroniclemaster1 Access 0 February 13th, 2008 04:55 AM
How to do line breaks! Apocolypse2005 Beginning VB 6 2 December 11th, 2006 03:20 PM
Want to detect line breaks conundrum Classic ASP Basics 1 October 3rd, 2003 04:05 AM
problems with line breaks sanchezal XSLT 7 July 30th, 2003 03:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.