|
こんなのでは
Option Explicit
Public Sub Sample_1()
Const cstrChar As String = "部:"
Dim i As Long
Dim vntData() As Variant
Dim strData() As Variant
Dim lngPos As Long
With ActiveSheet
vntData = Range(.Cells(1, "A"), .Cells(Rows.Count, "A").End(xlUp)).Value
End With
ReDim strData(1 To UBound(vntData, 1), 1 To 1)
For i = 1 To UBound(vntData, 1)
lngPos = InStr(1, vntData(i, 1), cstrChar, vbBinaryCompare)
If lngPos > 0 Then
strData(i, 1) = CStr(Val(Mid(vntData(i, 1), lngPos + Len(cstrChar))))
Else
strData(i, 1) = CStr(vntData(i, 1))
End If
Next i
ActiveSheet.Cells(1, "A").Resize(UBound(strData, 1)).Value = strData
End Sub
|
|