| 
    
     |  | こんなのでは? 
 Option Explicit
 
 Public Sub Sample()
 
 Dim i As Long
 Dim MM() As Variant
 Dim strPrompt As String
 
 ReDim MM(1 To 8)
 
 For i = 1 To 8
 MM(i) = Choose(i, "りんご", "みかん", "めろん", "りんご", "かき", "もも", "りんご", "みかん")
 Next i
 
 MM = Unique(MM)
 
 For i = LBound(MM) To UBound(MM)
 strPrompt = strPrompt & MM(i) & vbLf
 Next i
 
 MsgBox strPrompt, vbInformation
 
 End Sub
 
 Private Function Unique(vntData As Variant) As Variant
 
 '  列の値の重複取り
 
 Dim i As Long
 Dim j As Long
 Dim k As Long
 Dim vntList As Variant
 
 ReDim vntList(LBound(vntData, 1) To UBound(vntData, 1))
 
 k = LBound(vntList)
 vntList(k) = vntData(1)
 For i = LBound(vntData) + 1 To UBound(vntData)
 For j = LBound(vntList, 1) To k
 If vntList(j) = vntData(i) Then
 Exit For
 End If
 Next j
 If j > k Then
 k = j
 vntList(k) = vntData(i)
 End If
 Next i
 
 ReDim Preserve vntList(LBound(vntList) To k)
 
 Unique = vntList
 
 End Function
 
 |  |