| 
    
     |  | ▼りんご さん: >すいません。質問の仕方が悪かったようですね。
 >住所は例えで、住所の中には区がないものもあります。
 >
 >例  札幌市中央区中央町1丁目1-1
 >   小樽市小樽町1-1-1小樽マンション111
 >などが1000件ほどあります。
 >これを番地以降のマンション111に分けたかったのです。
 >わかりにくくてすいません。
 
 >元データ"L" 住所取り出し"P" アパート"Q"としたのですが
 横から失礼します。
 
 ○○番地○号でも対応できるように考えてみました。
 
 Sub Test()
 Dim Rexp As Object
 Dim st As String, st1 As String
 Dim Match As Object, Matches As Object
 Dim i As Long
 Set Rexp = CreateObject("VBScript.Regexp")
 Rexp.Pattern = "-[0-9,0-9]+[^-]|号"
 
 For i = 1 To Range("L" & Rows.Count).End(xlUp).Row
 st = Range("A" & i).Value
 Set Matches = Rexp.Execute(st)
 For Each Match In Matches
 If Match.Value = "号" Then
 st1 = Right(st, Len(st) - (Match.Length + Match.FirstIndex))
 Else
 st1 = Right(st, Len(st) - (Match.Length + Match.FirstIndex - 1))
 End If
 Exit For
 Next Match
 Range("P" & i).Value = Left(st, Len(st) - Len(st1))
 Range("Q" & i).Value = st1
 Next
 End Sub
 ご参考になれば。
 
 |  |