Hello,
I need your help with a script:
In my spreadsheet, in column E, starting at line 3 and going down, I have different postal code. Now what I want to do is that, if the 3 first digits from the postal code are followed by the same 3 last digits, in column F, it will write only the 3 first digits. If the 3 first are the same but the 3 last are not the same, it will write the entire postal code in column F.

EX:

"COL E" "COL F"
C2B 4F9 C2B
C2B 4F9 C2B
C9T 3R4 C9T 3R4
C9T 1J0 C9T 1JO

I have an error on my script:
Private Sub CommandButton3_Click()
'For the postal code
Sheets("TL Data ").Columns("F:F").Select
    Selection.Insert Shift:=xlToRight
    Range("F3").Select
     
    
    Set MaZone = Range("E3:" & Range("E65536").End(xlUp).Address)
For Each x In MaZone
    x.Offset(0, 1) = Split(x, " ")(0)
    Set c = MaZone.find(Split(x, " ")(0))
        firstAddress = c.Address
        Do
            If x.Value <> c.Value Then x.Offset(0, 1) = x: Exit Do
            Set c = MaZone.FindNext(c)
        Loop While c.Address <> firstAddress
Next
End Sub
It sais: Object variable or with block variable not set (run time error 91)

And it has to to i think with that section of the code:
firstAddress = c.Address
Thanks for your help.