I forgot to disable events, corrected code below. to look more
like Tom's <grin>.
Quote:
> I would suggest that you format the column as text so that you
> can place the zip codes from any country into it. Rather than
> restricting yourself to a specific format: however, you can
> use an Event macro. I guess the space bar is hard to find
> for hunt and peck typing.
> You can use an Event macro to captialize the entry and
> insert a space if you really have strictly Canadian zip codes.
> The following is an Event macro you can install by right
> clicking on the worksheet tab, view code, dump the following
> into the sheet module.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 7 Then Exit Sub
Dim str As String
str = UCase(Target.Value)
If Len(str) = 6 Then str _
= Left(str, 3) & " " & Right(str, 3)
Application.EnableEvents = False
Target.Value = str
Application.EnableEvents = True
End Sub
Quote:
> US zip codes are 5 numbers or 9 numbers (zip+4).
> --
> ---
> HTH,
> David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
> My Excel Macros: http://www.mvps.org/dmcritchie/excel/excel.htm
> Search Page: http://www.mvps.org/dmcritchie/excel/search.htm
> > Hello everyone,
> > I would like to include in my database a cell format that
> > would enable a user to enter a Canadian postal code.
> > American postal codes have 5 numbers, Canadian codes
> > require a letter, a number, a letter (space) a number , a
> > letter and a final number. Looks something like this:
> > H9J 1B5. How do I go about creating that personnalized
> > format? Can we do something so that whoever is doing data
> > entry doesn't have to manually put a space in between and
> > enter the capital letters (or activate the Caps Lock)?
> > Thanks!