- ©«¤l
- 8
- ¥DÃD
- 3
- ºëµØ
- 0
- ¿n¤À
- 11
- ÂI¦W
- 0
- §@·~¨t²Î
- Window 8
- ³nÅ骩¥»
- OFFICE 2007
- ¾\ŪÅv
- 10
- ©Ê§O
- ¤k
- µù¥U®É¶¡
- 2014-11-7
- ³Ì«áµn¿ý
- 2015-3-11
|
¦^´_ stillfish00
¦pªG§Ú¬O·QÅçµý§Úªºexcel order form sheet ¸Ìªºrange ¡]h19¡^customer post code ...
hildaliu µoªí©ó 2014-11-18 21:49 
i just tried this code , is this correct or not?- Sub UK_Postcodes()
- Dim RegExp As Object, Collection As Object, RegMatch As Object
- Dim Myrange As Range, C As Range, Outstring As String
- Set RegExp = CreateObject("vbscript.RegExp")
- With RegExp
- .Global = False
- .Pattern = "^([A-Z]{1,2}\d(\d|[A-Z])?|GIR) \d[A-Z]{2}$"
- End With
- Set Myrange = Range("h19")
- Outstring = ""
- Set Collection = RegExp.Execute(ActiveCell.Value)
- For Each RegMatch In Collection
- Outstring = Outstring & RegMatch
- Next
- If Range("h19").Value <> "" And Range("h19").Value = Outstring Then
- MsgBox "Valid UK Postcode"
- Else
- MsgBox "Invalid UK Postcode"
- End If
- Set Collection = Nothing
- Set RegExp = Nothing
- Set Myrange = Nothing
- End Sub
½Æ»s¥N½X |
|