Replace Function
Replace Function
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Replace Function

  1. #1
    Guest

    Default

     
    I want to be able to replace all occurences of "/" with "-" in VBA.

    how do i do that? what function should i use?

    i could use instr() to search, and then manually replace that. was wondering if there is a better way of doing that.

    tks folks for ur help

  2. #2
    MrExcel MVP Russell Hauf's Avatar
    Join Date
    Feb 2002
    Location
    Portland, OR Area - USA
    Posts
    1,605
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-21 10:22, Anonymous wrote:
    I want to be able to replace all occurences of "/" with "-" in VBA.

    how do i do that? what function should i use?

    i could use instr() to search, and then manually replace that. was wondering if there is a better way of doing that.

    tks folks for ur help
    If you have Excel 2000, you can use the replace function. Otherwise, you can do something like this:

    Code:
    Do While InStr(MyString, "/")
      Mid(MyString, InStr(MyString, "/"), 1) = "-"
    Loop
    Hope this helps,

    Russell

  3. #3
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    How's this (an example):

    MsgBox WorksheetFunction.Substitute("2/12/2002", "/", "-")

    Cheers,

    Nate

    [ This Message was edited by: NateO on 2002-02-21 10:36 ]

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com