1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Sub test() Set w = ActiveSheet Dim reg As Object Set reg = CreateObject("VBScript.RegExp") reg.pattern = "\D-[0-9]{3,4}" reg.IgnoreCase = True reg.Global = False For r = 2 To 6113 Set m = reg.Execute(w.Cells(r, 4).Value) If m.Count > 0 Then tmp = Split(m.Item(0).Value, "-")(1) ' 指定の文字列より右側を取得 w.Cells(r, 10).Value = tmp End If Next End Sub |