View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Substitute() & Char() in Macro

Substitute is a worksheet function. Try

Worksheetfunction.Substitute.

Or else try

VBscript function REPLACE()


If this post helps click Yes
---------------
Jacob Skaria


"Jeremy" wrote:

I am trying to write a macro to remove white space in my excel spreadsheet. I
have following script but it says my sub or function not defined, but if I
use it in excel (not macro) it actually works. Any idea? Thanks.

Sub WhiteSpaceRemover()

Application.ScreenUpdating = False

For Each cell In Selection
cell.Value = Trim(Substitute(cell.Value, CHAR(160), CHAR(32)))
Next cell

End Sub