#1   Report Post  
Posted to microsoft.public.excel.misc
lasca
 
Posts: n/a
Default Find and replace

I am trying to create a function that must look at a cell if the cell
contains EG. "/" it must replace it with an "_" and then return the value of
the cell, if it does not contain a "/", it must return the value as is.

The code that I used works fine but if it does not contain a "/" it returns
a error #value!

Here is code that i used pls help!


Function FReplace1(ReplaceField1) As String


If
Application.WorksheetFunction.IsNumber(Application .WorksheetFunction.Search("/", ReplaceField1)) = "true" Then
ReplaceField1 = Replace(ReplaceField1, "/", "_")
FReplace1 = ReplaceField1

Else

FFeplace1 = ReplaceField1
End If

End Function

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
Stefi
 
Posts: n/a
Default Find and replace

FFeplace1 = ReplaceField1
There is a typo in this line: Type FReplace1 instead of FFeplace1

Regards,
Stefi

  #3   Report Post  
Posted to microsoft.public.excel.misc
lasca
 
Posts: n/a
Default Find and replace

HI, 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 String


If
Application.WorksheetFunction.IsNumber(Application .WorksheetFunction.Search("/", ReplaceField1)) = "true" Then
ReplaceField1 = Replace(ReplaceField1, "/", "_")
FReplace1 = ReplaceField1

Else

FReplace1 = ReplaceField1
End If

End Function

"Stefi" wrote:

FFeplace1 = ReplaceField1

There is a typo in this line: Type FReplace1 instead of FFeplace1

Regards,
Stefi

  #4   Report Post  
Posted to microsoft.public.excel.misc
Stefi
 
Posts: n/a
Default Find and replace

Function FReplace1(ReplaceField1) As String
FReplace1 = Replace(ReplaceField1, "/", "_")
End Function
But you get the same with this worksheet function:
=SUBSTITUTE(A1,"/","_")
Regards,
Stefi


€˛lasca€¯ ezt Ć*rta:

HI, 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 String


If
Application.WorksheetFunction.IsNumber(Application .WorksheetFunction.Search("/", ReplaceField1)) = "true" Then
ReplaceField1 = Replace(ReplaceField1, "/", "_")
FReplace1 = ReplaceField1

Else

FReplace1 = ReplaceField1
End If

End Function

"Stefi" wrote:

FFeplace1 = ReplaceField1

There is a typo in this line: Type FReplace1 instead of FFeplace1

Regards,
Stefi

  #5   Report Post  
Posted to microsoft.public.excel.misc
lasca
 
Posts: n/a
Default Find and replace

Thank you!!!!!!!

I have been battling with this for days!!!



"Stefi" wrote:

Function FReplace1(ReplaceField1) As String
FReplace1 = Replace(ReplaceField1, "/", "_")
End Function
But you get the same with this worksheet function:
=SUBSTITUTE(A1,"/","_")
Regards,
Stefi


€˛lasca€¯ ezt Ć*rta:

HI, 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 String


If
Application.WorksheetFunction.IsNumber(Application .WorksheetFunction.Search("/", ReplaceField1)) = "true" Then
ReplaceField1 = Replace(ReplaceField1, "/", "_")
FReplace1 = ReplaceField1

Else

FReplace1 = ReplaceField1
End If

End Function

"Stefi" wrote:

FFeplace1 = ReplaceField1
There is a typo in this line: Type FReplace1 instead of FFeplace1

Regards,
Stefi

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 & Replace woes SlipperyPete Excel Worksheet Functions 2 March 31st 06 10:51 PM
Find and Replace blakrapter Excel Worksheet Functions 3 December 15th 05 12:25 AM
find and replace, within workbook Matt Carter Excel Discussion (Misc queries) 1 November 22nd 05 12:55 AM
Find and replace of word causes change of font formatting jwa90010 New Users to Excel 4 July 22nd 05 08:10 PM
VB Find and Replace Bony_Pony Excel Worksheet Functions 10 December 6th 04 05:45 PM


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