Results 1 to 2 of 2

Thread: Change String

  1. #1
    VBAX Regular
    Aug 2019

    Change String

    Hi Everyone . I have a string "Mel\EGGER\mdf.p2m" and i'd like to change in to "\EGGER\mdf.png" Does any of you know to tell me to do it? Thank you for your time Kostas

  2. #2
    VBAX Wizard
    Apr 2007
    Seems awfully specific - fastest would be to just re-type it

    Here's a User Defined Function that you can put in a worksheet or use in a VBA macro

    Option Explicit
    Sub test()
        MsgBox ChangeString("Mel\EGGER\mdf.p2m")
    End Sub
    Function ChangeString(s As String) As String
        Dim i As Long
        i = InStr(s, Application.PathSeparator)
        s = Right(s, Len(s) - i + 1)
        i = InStrRev(s, ".")
        s = Left(s, i) & "png"
        ChangeString = s
    End Function
    Last edited by Paul_Hossler; 09-21-2020 at 05:56 PM.


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums

Posting Permissions

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