Results 1 to 37 of 37

Format Cells for UK Postcode

Threaded View

MikeWaring Format Cells for UK Postcode 11-26-2010, 06:48 AM
TMS Re: Format Cells for UK... 11-26-2010, 07:05 AM
StephenR Re: Format Cells for UK... 11-26-2010, 07:08 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 08:21 AM
Richard Buttrey Re: Format Cells for UK... 11-26-2010, 07:09 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 09:35 AM
sweep Re: Format Cells for UK... 11-26-2010, 07:16 AM
StephenR Re: Format Cells for UK... 11-26-2010, 07:25 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 09:21 AM
Marcol Re: Format Cells for UK... 11-26-2010, 08:15 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 09:47 AM
StephenR Re: Format Cells for UK... 11-26-2010, 08:22 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 09:26 AM
TMS Re: Format Cells for UK... 11-26-2010, 09:31 AM
StephenR Re: Format Cells for UK... 11-26-2010, 09:48 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 09:52 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 11:18 AM
StephenR Re: Format Cells for UK... 11-26-2010, 10:03 AM
TMS Re: Format Cells for UK... 11-26-2010, 10:31 AM
Marcol Re: Format Cells for UK... 11-26-2010, 10:36 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 11:39 AM
Marcol Re: Format Cells for UK... 11-26-2010, 11:30 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 11:51 AM
TMS Re: Format Cells for UK... 11-26-2010, 11:30 AM
MikeWaring Re: Format Cells for UK... 11-26-2010, 01:09 PM
StephenR Re: Format Cells for UK... 11-26-2010, 11:34 AM
TMS Re: Format Cells for UK... 11-26-2010, 11:44 AM
StephenR Re: Format Cells for UK... 11-26-2010, 12:06 PM
Marcol Re: Format Cells for UK... 11-26-2010, 12:07 PM
TMS Re: Format Cells for UK... 11-26-2010, 12:17 PM
TMS Re: Format Cells for UK... 11-26-2010, 01:26 PM
MikeWaring Re: Format Cells for UK... 11-26-2010, 03:42 PM
TMS Re: Format Cells for UK... 11-26-2010, 02:23 PM
Marcol Re: Format Cells for UK... 11-26-2010, 03:27 PM
TMS Re: Format Cells for UK... 11-26-2010, 04:13 PM
Michael Spedding Re: Format Cells for UK... 12-02-2014, 12:06 PM
TMS Re: Format Cells for UK... 12-02-2014, 07:52 PM
  1. #1
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Thumbs up Format Cells for UK Postcode

    Hi, I posted this thread recently but since then I've managed to solve part of what I need to achieve. So in order to not waste the experts' time, I've closed the original post and resubmitted it to reflect my current query.

    I have a worksheet that is overwritten daily and contains address and details of customers who have purchased goods from our website in the previous 24hrs. The customer addresses are UK, Ireland and Europe.

    I need to get the UK postcodes formatted to the put the space in the correct place.

    There are many variations of the UK postcode and in addition the downloaded postcode data doesn't always have the space in the correct place, sometimes there's no space at all.

    The correct format is that irrespective of the number of characters in the postcode, there is always one space 3 characters from the right. (eg AB12[space]3DL or L3[space]2RM)

    I have written a macro using mouse clicks, but I realise this is probably very clunky, longwinded and bloated with code. In addition, it formats ALL postcodes in the worksheet, which is not what I need.

    The worksheet contains varying numbers of rows each day, depending on number of sales, so the formatting will need to process all rows containing data, then stop when it has processed the last row.

    The "Postcode" field cells are in Col J and the" Country Name" cells are in Col K.

    This is basically what I would like to achieve:-
    1) - If the cell in Col K = "United Kingdom", format cell J in the same row. Do this for all rows containing data.


    The code I have currently is:-

    Code:
    Sub PostCode_Format()
    '
    
        Columns("J:J").Select
        Selection.Copy
        Selection.Insert Shift:=xlToRight
        Application.CutCopyMode = False
        Range("K2").Select
        
    
        ActiveCell.FormulaR1C1 = "=PERSONAL.XLS!REVERSETEXT(SUBSTITUTE(RC[-1],"" "",""""))"
        Selection.AutoFill Destination:=Range("K2:K400"), Type:=xlFillDefault
        Range("K2").Select
        
        Columns("K:K").Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        
    
        Range("J2").Select
        ActiveCell.FormulaR1C1 = _
            "=UPPER(PERSONAL.XLS!REVERSETEXT(REPLACE(RC[1],3,1,MID(RC[1],3,1)&"" "")))"
        
    
        Selection.AutoFill Destination:=Range("J2:J400"), Type:=xlFillDefault
        Range("J2:J400").Select
        Columns("J:J").Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        Columns("K:K").Select
        Selection.Delete Shift:=xlToLeft
        Range("A1").Select
    End Sub
    Hope someone can help me resolve this!!!
    Last edited by MikeWaring; 11-26-2010 at 03:49 PM. Reason: Case solved

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