|
▼マクロ勉強中です。。 さん:
Sub test5()
Dim r As Range, c As Range
Dim v() As String, e
Dim s1 As String, s2 As String, s3 As String
Dim n As Long
If TypeName(Selection) <> "Range" Then Exit Sub
Set r = Selection
If r.Columns.Count > 1 Then Exit Sub
If WorksheetFunction.CountA(r) = 0 Then Exit Sub
ReDim v(1 To r.Count, 1 To 1)
For Each c In r
For Each e In Split(c.Value, " ")
s2 = " " & e & " "
If InStr(s1, s2) = 0 Then
s1 = s1 & s2
s3 = s3 & " " & e
End If
Next
If Len(s3) > 0 Then
n = n + 1
v(n, 1) = Mid(s3, 2)
s3 = ""
End If
Next
r.Value = v
End Sub
|
|