+ Reply to Thread
Results 1 to 27 of 27

Format Canadian Postal Code on Entry

Hybrid View

  1. #1
    Registered User
    Join Date
    02-19-2013
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2011
    Posts
    1

    Re: Format Canadian Postal Code on Entry

    Quote Originally Posted by mudraker View Post
    Gos-C

    Try this macro - It does not verify Letters & Number are placed in the correct order - This can be added if required.

    Copy this macro
    Goto Excel
    Right Click on Sheet Name Tab > select View Code
    Past macro into the Worksheet Module displayed

    Change Column number to suit (shown In red in this posting)
    Return to Excel and test


    Private Sub Worksheet_Change(ByVal Target As Range)
       Dim Rng As Range
       
       For Each Rng In Target
          If Rng.Column = 1 Then
             Application.EnableEvents = False
             Select Case Len(Rng.Value)
             Case 6
                Rng.Value = UCase(Left(Rng.Value, 3) & " " & Right(Rng.Value, 3))
             Case 7
                Rng.Value = UCase(Rng.Value)
             End Select
          End If
       Next Rng
       Application.EnableEvents = True
    End Sub
    Hi Mudraker,

    This work is fantastic and thank you in advance on behalf of all Canadian excel users who have been loosing sleep in trying to automate the post code entry/ format process!

    I am a Excel 2011 for Mac user and when I right click on the Sheet Tab, I do not have an option to View Code. I tried pasting the code into the macro record window but now every entry in the sheet comes up with an 'Invalid Postal Code' error.

    Could you please offer some (more!) guidance?

  2. #2
    Registered User
    Join Date
    02-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Format Canadian Postal Code on Entry

    Does anyone know if I can use this code to force postal code entry in a user form text box?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1