Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default copy & replace questions

Hi - closely-related find & replace questions for Excel (or Word if
necessary??):

1. Can I remove white space from the beginning of (a range of) cells?
2. Is there a "replace" wildcard that matches "the first captured
regular expression," as in Perl? That is, can Excel find
<whitespace<number and replace it with <number - that is, replacing
<number with *itself*, rather than with anything else?

Thanks *very* much -
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 461
Default copy & replace questions

Not sure if this applies, but try using the Trim formula.

So if this was in A1

Test Trim

Would look like

Test Trim

If you used =Trim(A1)

"Guest3731" wrote:

Hi - closely-related find & replace questions for Excel (or Word if
necessary??):

1. Can I remove white space from the beginning of (a range of) cells?
2. Is there a "replace" wildcard that matches "the first captured
regular expression," as in Perl? That is, can Excel find
<whitespace<number and replace it with <number - that is, replacing
<number with *itself*, rather than with anything else?

Thanks *very* much -

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default copy & replace questions

TRIM function strips leading and trailing and extra spaces from strings.

See other reply for formula method cell by cell.

To TRIM a range in place you can use a macro.

Sub TRIM_EXTRA_SPACES()
Dim Cell As Range
For Each Cell In Selection
If (Not IsEmpty(Cell)) And _
Not IsNumeric(Cell.Value) And _
InStr(Cell.Formula, "=") = 0 _
Then Cell.Value = Application.Trim(Cell.Value)
Next
End Sub

To remove all whitespace you can use editreplace or a macro.

Public Sub Strip_WhiteSpace()
Selection.Replace what:=" ", _
replacement:="", lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub


Gord Dibben MS Excel MVP

On Wed, 7 May 2008 11:39:40 -0700 (PDT), Guest3731
wrote:

Hi - closely-related find & replace questions for Excel (or Word if
necessary??):

1. Can I remove white space from the beginning of (a range of) cells?
2. Is there a "replace" wildcard that matches "the first captured
regular expression," as in Perl? That is, can Excel find
<whitespace<number and replace it with <number - that is, replacing
<number with *itself*, rather than with anything else?

Thanks *very* much -


  #4   Report Post  
Posted to microsoft.public.excel.misc
OP OP is offline
external usenet poster
 
Posts: 1
Default copy & replace questions

Gord Dibben wrote:
[snip macro solutions]


Thanks much for both responses -
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
find and replace help with copy paste Alex43 Excel Discussion (Misc queries) 1 March 17th 08 11:13 PM
How can i copy the values derived from find and replace? clem Excel Discussion (Misc queries) 2 March 10th 08 02:55 AM
Some questions on copy/paste in excel 97 Adam Kroger Excel Discussion (Misc queries) 4 November 23rd 05 01:08 AM
Copy over files/replace (complete question) G3£Wh\)zZ@ New Users to Excel 1 October 10th 05 10:38 AM
Find & Replace questions David Excel Worksheet Functions 1 November 2nd 04 06:41 PM


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

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

About Us

"It's about Microsoft Excel"