View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default Repeat keystrokes to delete character in column

You seem to be doing a little more than adding 27 in front of the phone
number... you also seem to be deleting the first character of the phone
number first. See if you can use one of these (depending on what you
actually want to do)...

To just add 27 in front of cell content...

Sub Add27()
Selection.Value = "27" & Selection.Value
End Sub

To replace the first character of cell with 27...

Sub Add27()
Selection.Value = "27" & Mid(Selection.Value, 2)
End Sub

Rick


"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!