View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default Remove Leading Comma

The RIGHT function keeps as many characters as you specify from the right (or
end) of a string (the cell's value, in your case). You want to keep all the
characters except the leftmost one (the comma to be removed).

If E10 contains ,12345
Then =RIGHT(E10,LEN(E10)-1) in another cell will return 12345

Hope this helps,

Hutch

"Katie" wrote:

Even if I want to remove the comma at the beginning of the cell?

I'm sorry- i thought leading was beginning and trailing was ending. I had
used the Right function for the end of the cell.

"Tom Hutchins" wrote:

If you want to remove a leading comma, you will need the RIGHT function
instead of the LEFT function:

cell.Value = Right(cell.Value, Len(cell.Value) - 1)

Hope this helps,

Hutch

"Katie" wrote:

Hello all- I know that we spoke before about removing a trailing comma, so i
tried to amend that code to remove a leading comma from a range, but it's not
working in cells where there's anything after the comma. Could anyone point
out what I did wrong with this code?

Range("I3:I10").Select
For Each cell In Selection
If Left(cell.Value, 1) = "," Then
cell.Value = Left(cell.Value, Len(cell.Value) - 1)
End If
Next