+ Reply to Thread
Results 1 to 5 of 5

Find and replace

  1. #1
    lasca
    Guest

    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. #2
    Stefi
    Guest

    RE: Find and replace

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

    Regards,
    Stefi


  3. #3
    lasca
    Guest

    RE: 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. #4
    Stefi
    Guest

    RE: 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. #5
    lasca
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1