View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David Biddulph[_2_] David Biddulph[_2_] is offline
external usenet poster
 
Posts: 8,651
Default Repeat keystrokes to delete character in column

I'm no VBA expert either, but I think you could change your example to:

Sub Add27()
Dim myCell As Range
For Each myCell In Selection
myCell.Value = "27" & Right(myCell.Value, Len(myCell.Value) - 1)
Next myCell
End Sub

You said: " But that deletes the last 4 characters. 'm not sure how it is
identifying the last 4!", to which the answer is that your Remove4 routine
uses the LEFT function, and the LEN function. [If you don't know how any
Excel functions work, look them up in Help.]

In the modified routine I have merely replaced the LEFT by RIGHT, and used
it to remove 1 character, not 4. I have concatenated the 27 on the front.
--
David Biddulph
"Graeme at Raptup" wrote in
message ...
Hi,
I have a column with mobile telephone numbers. e.g. 0846578902. (The cell
is
format to text not number)
Now I need to add a 27 in front of each to become 27846578902

I'm sure this can be done with a macro but am not too familiar with vb.
I had seen this in an earlier thread;

Sub Remove4()
Dim myCell As Range
For Each myCell In Selection
myCell.Value = Left(myCell.Value, Len(myCell.Value) - 4)
Next myCell
End Sub

But that deletes the last 4 characters. 'm not sure how it is identifying
the last 4!