View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Simon Shaw[_2_] Simon Shaw[_2_] is offline
external usenet poster
 
Posts: 2
Default Replace Space charcter in a string variable

Here is the code I used
-----------------------------------------

On Error Resume Nex

FileSaveName = Application.GetSaveAsFilename("K:\Excel_Keyword\",
fileFilter:="Text Files (*.txt), *.txt"

space_position = Application.WorksheetFunction.Find(" ", FileSaveName

If Err = 0 Then MsgBox "Spaces have been found in your file name," & vbCrLf &
"they will be replaced with underscores

Do While Err =
FileSaveName = Application.WorksheetFunction.Replace
(Arg1:=FileSaveName, Arg2:=space_position,
Arg3:=1, Arg4:="_"
space_position = Application.WorksheetFunction.Find(" ", FileSaveName
Loo

Err.Clea