Thread: Replace string
View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1958_] Rick Rothstein \(MVP - VB\)[_1958_] is offline
external usenet poster
 
Posts: 1
Default Replace string

Use kycode = "'01 (with the leading apostrophe) in your tbl.Replace
statement...

tbl.Replace "", kycode, xlWhole, xlByColumns, False '''=1

and follow it immediately with this statement...

tbl.Value = tbl.Value

It looks like doing this removes the leading asterisks from all the '01
values.

Rick


"Geoff" wrote in message
...
Hi Gary"s Student
Interesting enough, though the value in A1 is still prefixed as asiigned.
That's what I have to look out for. More important still is the dbf4 file
created after all my data sorting and cleaning does not import the
apostrophe
- that's the prime criteria so I will go with the suggestion.
As I replied to Rick, the importance of Replace is significant to me in
terms of processing speed, please see my response; kycode was only an
example
of it's potential use in the project.
Many thanks for the interest and support, the reason why Replace does not
do
as expected still concerns but at least there is a fix.

Geoff


"Gary''s Student" wrote:

Fortunately the leading single quote is a PrefixCharacter that does not
appear in the cell. Try this out:

Sub DontQuoteMe()
s1 = "'01"
s2 = "Geoff"
Range("A1").Value = s1
Range("A2").Value = s2
Range("A3").Value = Range("A2").Value & Range("A1").Value
End Sub

and you will see that the single quote does not show up in A3 at all.
--
Gary''s Student - gsnu200787


"Geoff" wrote:

kycode is a construct from the wbook name so I could add the apostrophe
though it is ironic that prior to this I have spent a lot of effort
deleting
unwanted characters from the imported data I am processing <g

But it does work and it's woth going for. Thanks for that. I'm still
curious though as to why the string requires it.

Geoff

"Gary''s Student" wrote:

Instead of:
kycode="01"
use:
kycode="'01"
--
Gary''s Student - gsnu200787