View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default personnalize the value of a cell

Sheila

Where will you be entering the postal codes?

In any particular column or row?

There is no Custom Format for Canadian Postal codes that I have found.

You can use event code in the worksheet so that as you enter the code, it will
change to A1A 1A1

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column < 1 Then Exit Sub
On Error GoTo ErrHandler
Application.EnableEvents = False
With Target
.Formula = UCase(Target.Formula)
.Value = (Left(Target.Value, 3) & " " & Right(Target.Value, 3))
End With
ErrHandler:
Application.EnableEvents = True
End Sub

As written this event code operates on Column A only.

You can type the code in as upper or lower case. Will come out as upper case no
matter what.

Right-click on the sheet tab and "View Code"

Copy/paste the above into that sheet module.

Adjust for your column if needed.

i.e. for just column B edit to If Target.Column < 2 Then Exit Sub


Gord Dibben MS Excel MVP..................and fellow Canuck

On Fri, 13 Oct 2006 08:25:01 -0700, Sheila
wrote:


ok sorry,,,well ,I'm using a french version of windows xp and exel so,,, but
will do my best. try to explain,,, i wanna insert a value into a cell which
is the postal code of my client...Canada has no zip code as you do in the
US.. i know i can personnalize this value and be the one i want but do not
know how,,, so if you or anyone else can help me..... will be nice

thanks again