View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Help with Replace()

XL 97 vba help...
expression.Replace(What, Replacement, LookAt, SearchOrder, MatchCase, MatchByte)
XL2003 vba help...
expression.Replace(What, Replacement, LookAt, SearchOrder, MatchCase, MatchByte, SearchFormat, ReplaceFormat)

"expression" is a Range object.
--
Jim Cone
Portland, Oregon USA





wrote in message
2003, 2007

PER Excel VBA Help: (I guess you knew that!)

Replace(expression, find, replace[, start[, count[, compare]]])

The Replace function syntax has these named arguments:

Part Description
expression Required. String expression containing sub string to replace.
find Required. Substring being searched for.
replace Required. Replacement substring.
start Optional. Position within expression where substring search is to begin. If
omitted, 1 is assumed.
count Optional. Number of substring substitutions to perform. If omitted, the
default value is 1, which means make all possible substitutions.
compare Optional. Numeric value indicating the kind of comparison to use when evaluating
substrings. See Settings section for values.

That said, I "assume" that Start is "Position within expression where substring search is to begin."

Facts:
StrToSearch = 'Min. Int.'!D18-362
StrToFind = "-362"

All is OK with:
Replace(StrToSearch, StrToFind, "",1,1,vbTextCompare)

What I want is to assure that the -362 is in the 16th start position - to be more accurate.

But if I specify Replace(StrToSearch, StrToFind, "",16,1,vbTextCompare) then
I get an empty string

What am I doing wrong?

Further, I know that the string I wish to delete from StrToSearch is Mid(StrToSearch,16,4)
How can I delete/Replace that exact string "-362" from its exact position in StrToSearch?

Any Thoughts appreciated,

Thanks, EagleOne