0
連続していない値のスプレッドシートをループし、その値を残りの配列ディメンションをインクリメントして値を配列に追加する前に、配列に以前に読み込まれた値。病気は以下の少しの例で説明しようとする。VBA内の配列の値を比較し、配列をインクリメントしない、または重複していない場合は値を加算しない
すなわち
Sub ArrayCompare()
Dim Cntry() As String
ArrayDim = 5 'The array is dimensioned with another counter that is not pertinent to this question but typically not greater than 5 in 1 dimension
ReDim Cntry(ArrayDim)
Range("C1").Select
Dim Counter As Integer
Counter = 8 'In the real spread sheet the counter is dynamic, ive just put this in as an example
Do Until Counter = 0
ArrayCounter = 0 'This is used to compare the array values Cntry(C0)
Do Until ActiveCell.Value <> ""
If ActiveCell.Value = "" Then
ActiveCell.Offset(1, 0).Select
Else: End If
Loop
If Active.Value = Cntry(ArrayCounter - 1) Or ActiveCell.Value = Cntry(ArrayCounter - 2) Or ActiveCell.Value = Cntry(ArrayCounter - 3) Or ActiveCell.Value = Cntry(ArrayCounter - 4) Then 'this doesn't work because the array is not dimensioned to this size yet.
ActiveCell.Offset(1, 0).Select
Else
Cntry(ArrayDim) = ActiveCell.Value
ArrayDim = ArrayDim + 1
End If
Counter = Counter - 1
Loop
End Sub
私は私と一緒にとても裸メモリから迅速にこれを行なったし、ご質問があれば私に知らせてください。
辞書を使用して一意のリストを作成することで、同じことを配列で行うことができます。 –
答えを見てください[こちら](http://stackoverflow.com/questions/5890257/populate-unique-values-into-a-vba-array-from-excel)あなたのために働くでしょう。 –