Creating a Macro to Delete Commas

  • Thread starter Thread starter rontap
  • Start date Start date
R

rontap

I have an excel file that the size will varry. I need a macro that wil
check all the fields for a comma. If there is one I would like to ge
rid of it. Does anyone have any idea how to do this? I have no idea an
I have been assigned this task.

Hel
 
Ron
Why not use Edit>Replace. Just leave the "replace with" field empty

Regards
Mark Graesse
(e-mail address removed)

----- rontap > wrote: ----

I have an excel file that the size will varry. I need a macro that wil
check all the fields for a comma. If there is one I would like to ge
rid of it. Does anyone have any idea how to do this? I have no idea an
I have been assigned this task

Hel
 
I would however, I will be relying on users to do this. I don't thin
the users will remember to keep doing it
 
If you can have users select the area of data where
you wish to remove the commas, this little
unsophisticated macro should work. Select and run.
just paste it in. perhaps assign a key stroke.

Sub RemoveComma()
Dim r As Range
Dim cPos As Integer
Set r = Selection
For Each c In r
cPos = InStr(1, c, ",")
While cPos
c.Value = Left(c, cPos - 1) + Right(c, Len(c) - cPos)
cPos = InStr(1, c, ",")
Wend
Next c
End Sub
-----Original Message-----
I have an excel file that the size will varry. I need a macro that will
check all the fields for a comma. If there is one I would like to get
rid of it. Does anyone have any idea how to do this? I
have no idea and

jr
 
Back
Top