I am trying to create a function that must look at a cell if the cell
contains EG. quot;/quot; it must replace it with an quot;_quot; and then return the value of
the cell, if it does not contain a quot;/quot;, it must return the value as is.
The code that I used works fine but if it does not contain a quot;/quot; it returns
a error #value!
Here is code that i used pls help!Function FReplace1(ReplaceField1) As StringIf
Application.WorksheetFunction.IsNumber(Application .WorksheetFunction.Search(quot;/quot;, ReplaceField1)) = quot;truequot; Then
ReplaceField1 = Replace(ReplaceField1, quot;/quot;, quot;_quot;)
FReplace1 = ReplaceField1
Else
FFeplace1 = ReplaceField1
End If
End Function
Thanks
gt; FFeplace1 = ReplaceField1
There is a typo in this line: Type FReplace1 instead of FFeplace1
Regards,
StefiHI, even with the typo corrrected - I am still getting the error.
Here is the corrected code, and I am still getting the error.
Function FReplace1(ReplaceField1) As StringIf
Application.WorksheetFunction.IsNumber(Application .WorksheetFunction.Search(quot;/quot;, ReplaceField1)) = quot;truequot; Then
ReplaceField1 = Replace(ReplaceField1, quot;/quot;, quot;_quot;)
FReplace1 = ReplaceField1
Else
FReplace1 = ReplaceField1
End If
End Function
quot;Stefiquot; wrote:
gt; gt; FFeplace1 = ReplaceField1
gt; There is a typo in this line: Type FReplace1 instead of FFeplace1
gt;
gt; Regards,
gt; Stefi
gt;
Function FReplace1(ReplaceField1) As String
FReplace1 = Replace(ReplaceField1, quot;/quot;, quot;_quot;)
End Function
But you get the same with this worksheet function:
=SUBSTITUTE(A1,quot;/quot;,quot;_quot;)
Regards,
Stefi?asca??ezt ?rta:
gt; HI, even with the typo corrrected - I am still getting the error.
gt;
gt; Here is the corrected code, and I am still getting the error.
gt;
gt; Function FReplace1(ReplaceField1) As String
gt;
gt;
gt; If
gt; Application.WorksheetFunction.IsNumber(Application .WorksheetFunction.Search(quot;/quot;, ReplaceField1)) = quot;truequot; Then
gt; ReplaceField1 = Replace(ReplaceField1, quot;/quot;, quot;_quot;)
gt; FReplace1 = ReplaceField1
gt;
gt; Else
gt;
gt; FReplace1 = ReplaceField1
gt; End If
gt;
gt; End Function
gt;
gt; quot;Stefiquot; wrote:
gt;
gt; gt; gt; FFeplace1 = ReplaceField1
gt; gt; There is a typo in this line: Type FReplace1 instead of FFeplace1
gt; gt;
gt; gt; Regards,
gt; gt; Stefi
gt; gt;
Thank you!!!!!!!
I have been battling with this for days!!!
quot;Stefiquot; wrote:
gt; Function FReplace1(ReplaceField1) As String
gt; FReplace1 = Replace(ReplaceField1, quot;/quot;, quot;_quot;)
gt; End Function
gt; But you get the same with this worksheet function:
gt; =SUBSTITUTE(A1,quot;/quot;,quot;_quot;)
gt; Regards,
gt; Stefi
gt;
gt;
gt; ?asca??ezt ?rta:
gt;
gt; gt; HI, even with the typo corrrected - I am still getting the error.
gt; gt;
gt; gt; Here is the corrected code, and I am still getting the error.
gt; gt;
gt; gt; Function FReplace1(ReplaceField1) As String
gt; gt;
gt; gt;
gt; gt; If
gt; gt; Application.WorksheetFunction.IsNumber(Application .WorksheetFunction.Search(quot;/quot;, ReplaceField1)) = quot;truequot; Then
gt; gt; ReplaceField1 = Replace(ReplaceField1, quot;/quot;, quot;_quot;)
gt; gt; FReplace1 = ReplaceField1
gt; gt;
gt; gt; Else
gt; gt;
gt; gt; FReplace1 = ReplaceField1
gt; gt; End If
gt; gt;
gt; gt; End Function
gt; gt;
gt; gt; quot;Stefiquot; wrote:
gt; gt;
gt; gt; gt; gt; FFeplace1 = ReplaceField1
gt; gt; gt; There is a typo in this line: Type FReplace1 instead of FFeplace1
gt; gt; gt;
gt; gt; gt; Regards,
gt; gt; gt; Stefi
gt; gt; gt;
- Aug 28 Tue 2007 20:39
Find and replace
close
全站熱搜
留言列表
發表留言