Replace Function

G

Guest

Guest
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 :)
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,882
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top