Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,345
Default Replace Macro

Using XL97.

If I enter 8:00 in A1, (formatted as h:mm), and then record a macro to
select A1 and replace a space with nothing, XL rightly tells me that if
cannot find any matching data to replace. However, if I then run the macro
that was recorded, (below), it changes the entry in A1 to 8:00:00AM ie it
removes the space between the 00 and the AM as if the entry had been 8:00:00
AM

Two questions:
1. I thought that formatting was just a mask over the *real* data in the
cell which is what is displayed in General format. If that is the case then
A1 would have held 0.33333333333333, so why does the VBA Replace find a
space? I suppose that the *Replace* in VBA is not the same *Replace* as the
one on the Edit menu but surely the data is 0.33333333333333 not a text
8:00:00 AM.

Sub Macro1()
Range("A1").Select
Cells.Replace What:=" ", Replacement:="", LookAt:=xlPart, SearchOrder:=
_
xlByRows, MatchCase:=False
End Sub

(I know that if I change it to LookAt:=xlWhole then it will not replace the
space but I can't understand how it happens in VBA but not manually.)

2. Does this just happen in XL97 or all versions?

--
Regards,

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk



 
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
Replace Vlookup with a macro Arain Excel Discussion (Misc queries) 1 September 27th 06 09:32 AM
Macro to Find & Replace [email protected] Excel Worksheet Functions 2 September 14th 06 07:17 PM
find&replace macro Elainey Excel Worksheet Functions 0 January 6th 06 09:20 PM
replace macro? andrewm Excel Worksheet Functions 1 October 19th 05 12:47 PM
Find & Replace in VB macro JackC Excel Discussion (Misc queries) 1 August 24th 05 09:22 PM


All times are GMT +1. The time now is 07:17 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"