 <p>You should add following line of code to your script:</p> <pre><code>If InStr(nshow, Sheets("Sheet2").Cells(i, j).Value) = 0 Then End If </code></pre> <p>Basically InStr function here checks if current iterated value is already in nshow array.</p> <p>If yes - it does nothing, if no (function returns 0) - it lets the inside block of code being run and as a result of this the new value is being added to the nshow array.</p> <p>Finally your code should look like this:</p> <pre><code>Dim txt, show As String Dim NameList(1 To 50) As Variant Dim i, j, t As Integer t = 1 For i = 1 To 10 For j = 1 To 5 If InStr(nshow, Sheets("Sheet2").Cells(i, j).Value) = 0 Then NameList(t) = Sheets("Sheet2").Cells(i, j).Value nshow = nshow &amp; i &amp; " " &amp; t &amp; " " &amp; NameList(t) &amp; vbCrLf t = t + 1 End If Next j Next i MsgBox nshow </code></pre>