Replace in VBA Excel

  • Thread starter Thread starter Maurice
  • Start date Start date
M

Maurice

In Visual basic you can use the Replace function to remove
unwanted characters. What would you use in VBA tom
accomplish the same. When I try to use the replace
function, it gives an error "Sub or function is not
defined"
Maurice
 
Maurice,

Replace was added to VBA in version 6, or Excel 2000, so it is not
available in earlier versions. In its place, you can use

Result = Application.WorksheetFunction.Substitute(...)

to call the SUBSTITUTE worksheet function from within VBA. See
help in Excel for SUBSTITUTE for syntax details.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Thanks,
That did it for me!!!!
Maurice
-----Original Message-----
Maurice,

Replace was added to VBA in version 6, or Excel 2000, so it is not
available in earlier versions. In its place, you can use

Result = Application.WorksheetFunction.Substitute(...)

to call the SUBSTITUTE worksheet function from within VBA. See
help in Excel for SUBSTITUTE for syntax details.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)







.
 
Back
Top