Change first character in a cell

  • Thread starter Thread starter houghi
  • Start date Start date
H

houghi

I have a list of +2000 phonenumbers and they are in the format of
012345678 but must become 3212345678, so the first 0 needs to become 32

I searched, but was unable to find a solution. Any idea?

houghi
 
In a "helper" column put:

="32"& RIGHT(A1,LEN(A1)-1)

Copy down.

Copy & Paste Special=>Values to remove" formula.
 
A macro perhaps:-

Sub changefirst()
Dim rcell As Range
Dim Myrange As Range
Dim maxval As Variant
Set Myrange = Range("A1:A100") '<Change to suit
newprefix = "32"
For Each rcell In Myrange
newvalue = newprefix & Mid(rcell.Value, 2, 99)
rcell.Value = newvalue
Next
End Sub

Mike
 
Apparently it contains an error.
In a "helper" column put:

="32"& RIGHT(A1,LEN(A1)-1)

Copy down.

Copy & Paste Special=>Values to remove" formula.


houghi
 
This works well enough, thanks.

Mike said:
A macro perhaps:-

Sub changefirst()
Dim rcell As Range
Dim Myrange As Range
Dim maxval As Variant
Set Myrange = Range("A1:A100") '<Change to suit
newprefix = "32"
For Each rcell In Myrange
newvalue = newprefix & Mid(rcell.Value, 2, 99)
rcell.Value = newvalue
Next
End Sub

Mike


houghi
 
Nothing wrong with Toppers' formula.

Apparently you typed or copied incorrectly.

But I see from other post you got the job done.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top