物は試しの、
Sub try2()
Dim re As Object
Dim Matches As Object
Dim i As Long
Dim a As String, v, x
With ActiveSheet
v = .Range(.[A1], .Cells(Rows.Count, 1).End(xlUp)).Value
ReDim x(1 To UBound(v, 1))
Set re = CreateObject("VBScript.RegExp")
re.Pattern = "\s{1}\D+"
For i = 1 To UBound(v, 1)
If re.test(v(i, 1)) Then
Set Matches = re.Execute(v(i, 1))
x(i) = Replace(v(i, 1), Matches.Item(0).Value, " ")
Else
x(i) = v(i, 1)
End If
Next
.Range("A:A").ClearContents
.Range("A1").Resize(UBound(v, 1), 1).Value = Application.Transpose(x)
.Columns("A:A").TextToColumns Space:=True
End With
Erase x
Set re = Nothing
End Sub
こんな感じでしょうか?
>漢字部分(会社名)だけを消去すればよいようです。
Sub try()
Dim re As Object
Dim Matches As Object
Dim a As String
a = Range("A1").Value
Set re = CreateObject("VBScript.RegExp")
re.Pattern = "\s{1}(\D+)"
If re.test(a) Then
Set Matches = re.Execute(a)
With Matches.Item(0)
Range("B1").Value = Replace(a, .Value, " ")
End With
End If
Set re = Nothing
End Sub
例えるなら、こうゆう事ですか?
お礼
いろいろありがとうございます これから試してみます vbは素人なので本を読みながら挑戦です これからもよろしくお願いします