View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jeff[_25_] Jeff[_25_] is offline
external usenet poster
 
Posts: 2
Default How can I insert a space before the last character in a range of cells

Wow, that was a fast response, thanks very much. That
works lovely except on completion it throws up an error
and starts debug with ref to the last line of code. run
time error 5 invalid procedure call or argument.

thid is my code -

Private Sub CommandButton1_Click()
Range("e2:e2000").Select
Application.CutCopyMode = False
Selection.Copy
Range("f2:f2000").Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("F2:F2000").Select
Selection.Replace What:=" ", Replacement:="",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Dim cell As Range
For Each cell In Selection
If Not cell.HasFormula Then _
cell.Value = Left(cell.Value, Len(cell.Value) - 1) & " " &
Right(cell.Value, 1)
Next
End Sub
-----Original Message-----
Sub Addspace()
Dim cell as Range
for each cell in selection
if not cell.hasformula then _
cell.value = left(cell.value,len(cell.value)-1) & " " &

Right(Cell.Value,1)
Next
End Sub
--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Any help greatly appreciated!

Jeff
MCP 70-215



.